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

Update Capture Files 1

Status
Not open for further replies.

MikieZ

IS-IT--Management
Jun 18, 2004
1
0
0
US
Hi All -

I have a script I found on this site (Thanks Knob!) that starts a new capture file on a daily basis. The script is at the bottom of this post.

I have 2 questions:

How does Procomm (by default) determine when to write to this file? It appears to me that it is about once an hour or perhaps when the buffer reaches 64K.

How can I force Procomm to write to this file about every 5 minutes?


TIA

Mike

proc main
string sFileName
string sPath

sPath = "S:\Logs\"

sFileName = getdate()
strcat sPath sFileName
set capture query off
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 data slated for the capture file is only saved when the capture file is closed with capture OFF command. The script you posted only does that at the beginning of each new day. To get the data to save every five minutes, you could add a when elapsed command to call a procedure to close and then reopen the capture file every five minutes. Bear in mind that this could result in a slight loss of data, but I think I have a decent workaround for that.

You would first need a line that looks like this:

when elapsed 0 600 call captureit

where 0 is just an integer ID, 600 is the number of seconds (five minutes to wait), and captureit is the name of the procedure to call.

You would then needing a corresponding procedure called captureit that looked something like this:

proc captureit
waitquiet 15 FOREVER
capture OFF
capture ON
endproc

The waitquiet command means that procedure will wait until no data has been received for 15 seconds, then close and reopen the capture file to save the data.



aspect@aspectscripting.com
 
Knob, Can you offer any tips on how I could modify this to just append the date to a file name in a script that I use to run some specific commands?

I don't really need a script that runs as a daily log or that saves every 5 minutes, but I run a lot of scripts periodically that save a specific capture file of the session and then I later manually file these or rename to add a date.



 
Sure, here is a quick example (I have a couple more on my site that show how to come up with different date formats if necessary):


proc captureit
integer iDay, iMonth, iYear, iHour, iMin, iSec
string sFileName

waitquiet 15 FOREVER
capture OFF
ltimeints $LTIME iYear iMonth iDay iHour iMin iSec

strfmt sFileName "%d%02d%02d" iYear iMonth iDay
strcat sFileName ".TXT"
set capture filename sFileName
capture ON
endproc

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

Part and Inventory Search

Sponsor

Back
Top