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!

How to ajust this script to print the timestamp and information in row

Status
Not open for further replies.

thomas200813

Programmer
Feb 12, 2007
8
CN
The result is below:

you could find the timestamp and received info is printed in seperate line.How could we change the script and print the info into the capture file in a row.
---------------------------------------------------------
|2/12/2007 1:55:00PM|
TsecStart: port 0, PHY 0, link is up at 100Mbps full duplex
|2/12/2007 1:55:00PM|
Attached IPv4 interface to mottsec unit 2
|2/12/2007 1:55:00PM|
Attached IPv4 interface to mottsec unit 0
|2/12/2007 1:55:00PM|
usrNetDevStart: configured IPC device mottsec0, address 192.168.10.1
|2/12/2007 1:55:00PM|

|2/12/2007 1:55:00PM|
Adding 15452 symbols for standalone.
|2/12/2007 1:55:01PM|


-------------------------------------------------------------
proc main
string DateString, TimeString, sCap
string CapName ; Name of capture file to open.
string datahold
; Grab current time and date and place them into those string variables
ltimestrs $LTIME DateString TimeString

; I found out that Procomm does not like slashes or colons in capture filenames
; so lets replace all of these offending delimiters with hyphens
strreplace DateString "/" "-" ;Replace all slashes in date string with hyphens
strreplace TimeString ":" "-" ;Replace all colons in time string with hyphens

; Now concatenate the capture filename together
strcat CapName "Procomm_Capture_"
strcat CapName DateString
strcat CapName "_"
strcat CapName TimeString
strcat CapName ".cap"
set capture overwrite on ; overwrite old capture file data with new data
set capture query off ; do not prompt user for caputre filename
set capture file CapName ; Set name of capture file (pieced together from above).
capture on ; Open up the capture file.

; We need to set up a "hook" to allow the capture file to be closed when a user
; stops the script.
when USEREXIT call close_capture

; Main capture loop. This is an infinite loop that grabs the current time, formats
; and dumps a time stamp string into the capture stream and then sleeps for 60 seconds
; before it does it again. This loop will run until the user stops the script or
; exits Procomm
while 1
ltimestrs $LTIME DateString TimeString
strfmt sCap "|%s %s|" DateString TimeString
rget datahold 256 FOREVER
strreplace sCap "'n" ""
strreplace sCap "'r" ""
strcat sCap datahold
capturestr sCap
endwhile

endproc

proc close_capture
string DateString, TimeString, sCap

; Drop a final timestamp into the capture file before closing
ltimestrs $LTIME DateString TimeString
strfmt sCap "|%s %s|" DateString TimeString
capturestr sCap
capture off ; Close the capture file.
exit
endproc
 
Instead of:

Code:
strreplace sCap "'n" ""
strreplace sCap "'r" ""

Try:

Code:
strreplace sCap "`n" ""
strreplace sCap "`r" ""

Should be ` (under the ~, next to 1 on your keyboard) instead of ' (single quote.)

See if this helps.
 
It doesn't work too.Why does it come out in different row?
 
When I ran your script with kodr's change (and also without), I am getting the date and time on the same line as such:

|3/12/2007 4:44:59PM|

Is this not what you are wanting?

 
Hi Knod,

It is right that the time stamp is printed out in the log file.But I hope the time stamp and terminal mmi information come out in the same row.

That is

|3/12/2007 4:44:59PM|mmi information printed here



Regards

 
Thomas, in this code:

Code:
   while 1
   ltimestrs $LTIME DateString TimeString
   strfmt sCap "|%s %s|" DateString TimeString
   rget  datahold 256 FOREVER
   strreplace sCap "'n" ""
   strreplace sCap "'r" ""    
   strcat sCap datahold
   capturestr sCap
   endwhile

Could the CR & LF be part of the 'datahold' data?
Maybe try replacing the `r and `n to it also?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top