Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


RE: File Creation

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,29213
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> RE: File Creation
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: <<   < prev  1 [2] 3   next >   >>
Login
Message << Older Topic   Newer Topic >>
 RE: File Creation - 1/3/2006 10:33:25 PM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
I changed the line -

Dim oTSRes : Set oTSRes = oFS.CreateTextFile( "c:\Store\" & sShopNum & "\comms.scr" )

Which works fine as long as directory exists otherwise it errors out, which is fine.  The plan is to do this so that they are stored and ready to roll if they get deleted or someone does something stupid.

(in reply to ehvbs)
 
 
Post #: 21
 
 RE: File Creation - 1/4/2006 1:56:20 AM   
  Cybex


Posts: 412
Score: 0
Joined: 9/14/2005
From: Florida
Status: offline
I see what you mean.

Cybex

_____________________________

Common sense is not so common.

(in reply to ehvbs)
 
 
Post #: 22
 
 RE: File Creation - 1/4/2006 7:58:07 AM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
The next step is to go from fairly simple to advanced, is to get the program to read from an excel listing and then save them automatically.  Or atleast another version of the program to create them in numbers, while this version is their to make them individually.

(in reply to Cybex)
 
 
Post #: 23
 
 RE: File Creation - 1/4/2006 8:06:16 AM   
  ehvbs

 

Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Hi Navarre

what about using a text file to specify the ftp parameters? (that wouldn't go so
fast from simple to advanced)

(in reply to Navarre)
 
 
Post #: 24
 
 RE: File Creation - 1/4/2006 8:11:58 AM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
Sounds like a plan.

The only reason that I wanted to use Excel is that we have a sheet that generates the random passwords and then outputs them into another form.  So atleast this way if we need to mass update passwords (such as for when someone leaves) we can do it very easily.

Tim

(in reply to ehvbs)
 
 
Post #: 25
 
 RE: File Creation - 1/4/2006 8:17:12 AM   
  ehvbs

 

Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Take your pick:

  (1) a command line vbs script, that reads a text file (one line per .scr; params in order
        host ... shopnumber)

  (2) a command line vbs script, that reads a xls file (you have to deliver a sample)

(in reply to Navarre)
 
 
Post #: 26
 
 RE: File Creation - 1/4/2006 8:34:22 AM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
here is an example of the XLS file.

Store                  VPN       Mail         Local     Admin     Arrow    PCA     Updated

01 - Chatswood  ah2oFY   OUJT0H   HBXisx    OtzX5O     pluto       gaunt     Yes
02 - Sydney        Ngy8JJ   09OTFw   XnuSYV   6OX6Je    pluto        gaunt     Yes
03 - Newcastle   4fJun3    Mgraak     YyiQvM   Yek11o     pluto        gaunt     Yes

The VPN password is fairly straight forward, Local is the local User Account and Admin is the Local Admin, Arrow is a local application and PCA is for PC Anywhere.

The Mail password is their active directory password which what they use also to FTP into us.  The store is the store name and number, at this time it is one column but easy enough to split.

< Message edited by Navarre -- 1/4/2006 8:41:16 AM >

(in reply to ehvbs)
 
 
Post #: 27
 
 RE: File Creation - 1/4/2006 8:40:56 AM   
  ehvbs

 

Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Sorry Tim,

but I meant to ask you for a real .xls file (to access the data, I need to know
sheet name, rows, cols, headers ...). Of course the actual data values can be
faked and you may delete all the macros)

(in reply to Navarre)
 
 
Post #: 28
 
 RE: File Creation - 1/4/2006 8:43:51 AM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
Form emailed to you.

(in reply to ehvbs)
 
 
Post #: 29
 
 RE: File Creation - 1/4/2006 8:57:20 AM   
  ehvbs

 

Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Thanks, got it.

For the record, please check/fill in:

We need:

  dicMarkers.Add "§HOST§"   , sHost       <==  (?)
  dicMarkers.Add "§DomUser§", sDomUsr  <== col Local (?)
  dicMarkers.Add "§PassW§"  , sPassW    <==  col Mail
  dicMarkers.Add "§ShopNum§", sShopNum  <== Left( Store, 2 )

(in reply to Navarre)
 
 
Post #: 30
 
 RE: File Creation - 1/4/2006 9:12:07 AM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
There is no host in that file, but that would normally be 172.27.1.5.

The user name that they use to log in is gwshop(store number) - gwshop13.

(in reply to ehvbs)
 
 
Post #: 31
 
 RE: File Creation - 1/4/2006 9:19:08 AM   
  ehvbs

 

Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Does 'normally' mean, I can treat it as a constant (=> put it in the template)? Or is there
a hidden dependency shop => host?
Please explain "gwshop"

(in reply to Navarre)
 
 
Post #: 32
 
 RE: File Creation - 1/4/2006 9:21:31 AM   
  ehvbs

 

Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
In the mean time - try:


      

(in reply to ehvbs)
 
 
Post #: 33
 
 RE: File Creation - 1/4/2006 9:47:01 AM   
  ehvbs

 

Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Hey Tim - what are you doing? Are you ready for this:


      

(in reply to ehvbs)
 
 
Post #: 34
 
 RE: File Creation - 1/4/2006 9:50:54 AM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
Sorry I have just had a server fall over.

But yep I am ready.

(in reply to ehvbs)
 
 
Post #: 35
 
 RE: File Creation - 1/4/2006 11:17:06 AM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
That works lovely.  Though the one thing that I tried to do was add on a Country ie Oz or Nz and a Country Code 80 or 82.

I tried adding -

       dicMarkers.Add "§Country§"     , "?"
       dicMarkers.Add "§CountryCode§" , "?"

and further down I added -

     dicMarkers( "§Country§"    ) = sCountry
     dicMarkers( "§CountryCode§") = sCountryCode

I am guessing they did not work because there is nothing to define them earlier, I also added the column for each to the Excel sheet but still no good.

(in reply to ehvbs)
 
 
Post #: 36
 
 RE: File Creation - 1/4/2006 7:09:02 PM   
  ehvbs

 

Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Hi Tim,

what does "still no good" mean? Did you try:

  WScript.Echo oRS( "Store" ).Value, oRS( "Country" ).Value

and

  dicMarkers( "§CountryCode§") = oRS( "CountryCode" ).Value

What did you put in the template file?

(in reply to Navarre)
 
 
Post #: 37
 
 RE: File Creation - 1/4/2006 9:16:27 PM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
Here is the code as written, I made a small change to where it outputs the files.  I have made it a input box that asks it to specify, next I will look at setting some default information for it.

  Const adOpenForwardOnly =          0 ' 00000000
  Const adLockReadOnly    =          1 ' 00000001
  Const adCmdTable        =          2 ' 00000002

  Dim sXLSFSpec : sXLSFSpec = "N:\IT\Asset Register\Security\Store Details.xls"
  Dim sTblName  : sTblName  = "[Sheet2$]"
  Dim sTPLFSpec : sTPLFSpec = ".\commsboth2.000"
  Dim sOTPDir   : sOTPDir   = InputBox("Please Enter the Drive Path To Output To.  For Example C:\Shops\")

  Dim oFS        : Set oFS        = CreateObject( "Scripting.FileSystemObject" )
  Dim dicMarkers : Set dicMarkers = CreateObject( "Scripting.Dictionary"       )
  Dim sText0     : sText0         = oFS.OpenTextFile( sTPLFSpec ).ReadAll()

  If Not oFS.FolderExists( sOTPDir ) Then oFS.CreateFolder( sOTPDir )

  dicMarkers.Add "§HOST§"        , "172.27.1.5"
  dicMarkers.Add "§DomUser§"     , "?"
  dicMarkers.Add "§PassW§"       , "?"
  dicMarkers.Add "§ShopNum§"     , "?"
  dicMarkers.Add "§Country§"     , "Oz"
  dicMarkers.Add "§CountryCode§" , "80"

  Dim oCNCT : Set oCNCT = CreateObject( "ADODB.Connection" )
  Dim oRS   : Set oRS   = CreateObject( "ADODB.Recordset" )
  Dim sCNCT : sCNCT     =   "Provider=MSDASQL;"                        _
                          + "Driver={Microsoft Excel Driver (*.xls)};" _
                          + "DBQ=" + sXLSFSpec + ";"
  oCNCT.Open sCNCT
  oRS.Open sTblName, oCNCT, adOpenForwardOnly, adLockReadOnly, adCmdTable

  Do While Not oRS.EOF
     WScript.Echo oRS( "Store" ).Value

     Dim sShopNum : sShopNum = Left( oRS( "Store" ), 2 )
     Dim sOTPDir2 : sOTPDir2 = sOTPDir + sShopNum + "\"

     If Not oFS.FolderExists( sOTPDir2 ) Then oFS.CreateFolder( sOTPDir2 )

     Dim oTSRes   : Set oTSRes = oFS.CreateTextFile( sOTPDir2 + "comms.scr" )
     Dim sText1   : sText1 = sText0
     Dim sKey

     dicMarkers( "§DomUser§"    ) = "gwshop" + sShopNum
     dicMarkers( "§PassW§"      ) = oRS( "Mail"  )
     dicMarkers( "§ShopNum§"    ) = sShopNum
     dicMarkers( "§Country§"    ) = sCountry
     dicMarkers( "§CountryCode§") = sCountryCode

     oRS.MoveNext

     For Each sKey In dicMarkers.Keys
         sText1 = Replace( sText1, sKey, dicMarkers( sKey ) )
     Next
     oTSRes.Write sText1
     oTSRes.Close

  Loop

  oCNCT.Close


The config file is still the same -

open §HOST§
win2000\§DomUser§
§PassW§
bi
cd \comms\§Country§
lcd c:\arrow\comms
mput arr??r??.xfr
cd \comms\§Country§\upload
mget ARR??H§CountryCode§.XFR
cd \comms\§Country§
lcd c:\arrow\arr@data
mput r??-dcom.txt
mput r??-ucom.txt
lcd c:\data\forms
mput ???_w1.xls
lcd c:\temp
cd \comms\files
mget *.*
cd \comms\files\§Country§
mget *.*
cd \comms\files\§Country§\§ShopNum§
mget *.*
quit



(in reply to ehvbs)
 
 
Post #: 38
 
 RE: File Creation - 1/4/2006 9:22:56 PM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
That small bit worked just fine.

(in reply to Navarre)
 
 
Post #: 39
 
 RE: File Creation - 1/5/2006 5:39:56 AM   
  ehvbs

 

Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Hi Tim,

please be a little bit more specific! What's the bit that worked? Which bits
don't work?

Did you get correct values for Country/CountryCode in the resulting .scr
files? Looking at your code, I can't see where sCountry and sCountryCode
used in the lines

     dicMarkers( "§Country§"    ) = sCountry
     dicMarkers( "§CountryCode§") = sCountryCode

get their values from. Sorry for being terse, but right now I'm obliged
to waste my time on ActiveSync and Pocket PCs.

Ekkehard

(in reply to Navarre)
 
 
Post #: 40
 
 
Page:  <<   < prev  1 [2] 3   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> RE: File Creation Page: <<   < prev  1 [2] 3   next >   >>
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts