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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automated CAP File

Status
Not open for further replies.

willyd61

MIS
May 6, 2003
37
US
Hello,

I am new to Procomm and know nothing about it, I have looked thru the forums and found similiar scripts but was wondering if someone could just show me the light, as I only need this one script then I wont need to write anymore.

Basically I have many field devices dialing in via modem to procomm, sends text then disco's. This I know works as I can see the text come across the screen.

What I want is to capture this text all day long then, at midnight write to a file,with time/date stamp as the file name and start a new file.

Also how do I configure this script to start auto when procomm starts up?

Thanks ahead of time for all your help,
If anyone ever needs help with perl,php,etc feel free to email me.

-WL
 
This script should open a cature file based on the current date, then close it at midnight, rename the capture file to the new date, and open the new file:

proc main
string sFileName

sFileName = getdate()
set capture file sFileName
capture ON

when $DATE call newdate

while 1
yield
endwhile
endproc

proc newdate
string sFilename

capture OFF
sFileName = getdate()
set capture file sFileName
capture ON
endproc

func getdate : string
integer iDay, iMonth, iYear, iHour, iMin, iSec
string sFileName

ltimeints $LTIME iYear iMonth iDay iHour iMin iSec
strfmt sFileName "%d%02d%02d" iYear iMonth iDay
strcat sFileName ".TXT"
return sFileName
endfunc

The way the script works is it calls the getdate function, which returns a filename of the format YYYYMMDD.TXT based on the current date. The capture file is set to this date (note, you will want to use the set capture path command if you don't want the data saved in the default Procomm capture directory), then the file is opened. The while 1 loops means Procomm loops endlessly. The when $DATE command will fire whenever the date changes, which causes the newdate procedure to be called. The current capture file is closed, the new capture filename is computed, opened, and then the script continues looping and collecting date until midnight of the current day.

As for you launching the script automatically, you have a couple different options. You can specify a script file in the command line or shortcut you use to launch Procomm. You can also call your script from the startup.was script that is run each time Procomm is run by adding a chain statement to the end of that script.


aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top