Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script - Adding date to filename

Status
Not open for further replies.

irishhooligan

IS-IT--Management
Apr 26, 2004
90
US
I have a script to print the history file and save the file into a .txt file. However, I want to add the date to the filename. I've been looking at the Date variables in Procomm and could use some help. Heres my script:
;Recorded script. Editing may be required.
proc main
string fname
string pname
fname = "historyfile.txt" ;name of file where I want to add the date
pname ="C:\" ;path for file
set capture file fname
set capture path pname
capture on
transmit "LOGIN ^M"
waitfor "PASS?"
transmit "......^M"
waitfor ">"
transmit "LD 22^M"
waitfor "REQ "
transmit "PRT^M"
waitfor "TYPE "
transmit "AHST^M"
waitquiet 2 FOREVER
waitfor "REQ "
transmit "END^M"
waitfor ">"
transmit "LOGO^M"
transmit ">"
capture off
endproc
 
look at the data/paths options.. your path and name options have a date option.. i don't use it now but have in the past.. i now auto sort my capture folder by date which does almost the same thing.. if you can't find it, let us know, i'll look at the patch option

john poole
bellsouth business
columbia,sc
 
Irish,

I took your script and adjusted it some. This should include the date in your file name as requested. You will notice the "set path" and login/log out parts are gone. That was only because it made it easier to run on my machine. I'm sure you can add those parts back in with ease.

I also added a Tape ID at the start of the capture so you would know what switch you grabbed the history from.

There is also a line at the end to clear the assigned capture name. If you don't clear the capture name the next time you hit the capture button on the tool bar you would append the same file.

Ron


Code:
proc main
integer iDay, iMonth, iYear, iMin, iHour, iSec
string fname

ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
strfmt fname "History_%02d_%02d_%d_%d_%d.txt" iMonth iDay iYear iHour iMin 

set capture file fname
 
capture on
transmit "****^M"
   waitfor ">"
   transmit "LD 22^M"
   waitfor "REQ"
   transmit "TID^M"
   
waitfor "REQ "
transmit "PRT^M"
waitfor "TYPE "
transmit "AHST^M"
waitquiet 3 FOREVER
waitfor "REQ "
transmit "*^M"
transmit "END^M"
waitfor ">"

capture off
set capture file none  ;clears capture name
endproc
 
Irish,

Use this one. I had two lines near the end of the script reversed.

Ron

Code:
proc main
integer iDay, iMonth, iYear, iMin, iHour, iSec
string fname

ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
strfmt fname "History_%02d_%02d_%d_%d_%d.txt" iMonth iDay iYear iHour iMin

set capture file fname
 
capture on
transmit "****^M"
   waitfor ">"
   transmit "LD 22^M"
   waitfor "REQ"
   transmit "TID^M"
   
waitfor "REQ "
transmit "PRT^M"
waitfor "TYPE "
transmit "AHST^M"
waitquiet 3 FOREVER
transmit "*^M"
waitfor "REQ "
transmit "END^M"
waitfor ">"

capture off
set capture file none  ;clears capture name
endproc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top