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

Continuous Terminal logging

Status
Not open for further replies.

wayneboyd

Technical User
Feb 28, 2003
1
US
Help,

I am fairly new to Procomm Plus....Here is what I am atempting to accomplish.

I am using Procomm (4.8) to interface with our Inter-Tel PBX to track inboud and outbound calls. I need to capture the terminal output to a file as calls are logged in the terminal window. I tried to use a file called 'capture.wax', but does not continually run....it runs briefly and only creates a single capture. I need it to write to a text file as call come in and go out. I am sure that its simple, just can't put my finger on it. Anyway, here is the current script I am trying:

proc main

string Fname = "file.cap" ;File that holds the screen shots.
string pathname ;Path to the Capture directory.

dial DATA "Call Log" ; Dial Call Log entry.
while $DIALING ; Loop while dialing.
endwhile
set capture file Fname ; Set name of capture file.
set capture overwrite ON
fetch capture path pathname ;Command to find the current path to the Aspect directory.
capture on ; Open up the capture file.
while $CARRIER ; Loop while connected to remote.
yield ; Yield processing time
endwhile
capture off ; Close the capture file.
endproc

TIA

Wayne Boyd

 
Hello,

I have a Monitor Script at work on my Win 98SE Machine running Procomm 4.8. It captures Data on 30 Minute TimeFrames to a File. The Script uses Direct Connect to the Nortel Switch; but could be Modified for what you want to do. I can E-Mail it to you on Monday if you so desire.

Hank camphm@bellsouth.net
 
The one problem with capturing this data continually is that the information is not written to a file until you use the capture off command. However, if you do this and then use capture on to reopen the capture file, information currently on the screen will be duplicated in the capture file (unless you use the clear command). In cases like this, it's usually best to read the information directly as it comes in via the rget command, then write that information to a file. Note that this keeps the information from appearing on the screen, unless you use the termwrite command to print it out. I think I have a rough sample script that shows how to do this. I'll see if I can find it in my sent mail folder and post it later tonight or Sunday.
aspect@aspectscripting.com
 
Here's a sample I found in my sent mail that you may be able to twist to your needs:

proc main
string sCapFile = "c:\log.txt"
string sLine

set aspect rgetchar 10
while 1
rget sLine 80 FOREVER
if fopen 0 sCapFile APPEND TEXT
fputs 0 sLine
fclose 0
endif
termwrites sLine
endwhile
endproc

You will likely need to use the set rgetchar command to set what character (likely a carriage return or line feed) marks the end of each line sent by the remote system. You may also need to use the STRIP flag with the rget command so that character does not end up in the text file. Otherwise, the formatting of the file may be off (double spaced, for example). I'm not in a situation to test this at the moment, but hopefully this will work for your purposes.
aspect@aspectscripting.com
 
I wrote this script in 1999. It toggles two buffer files to capture CDR data. It ran continually for 13 months without restarting the 233 mhz Win 95 PC it was on. It collected over 1,000,000 call records a month.

[tt]
;Capture Utility for CDR Statistics
String DATEFNAME, BUFFERNOW, TODAY
String CDRSTATUS
;**********************************************
PROC MAIN
Integer NUMOFRECORDS
;Get today's date
When USEREXIT Call CLEARCAPTURE
pwtitlebar "CDR Capture and Archive Utility" ; Change Procomm Plus's title.
DATESTAMP()
Strcpy CDRSTATUS "Starting"
dialogbox 0 118 15 264 48 7 "CDR Data Collection"
text 1 64 13 148 22 CDRSTATUS center
enddialog
Goagain:
Strfind TODAY $DATE
If Failure
DATESTAMP()
Endif
BUFFERSETUP()
Capture OFF
CLEAR
Capture ON
;Move buffer data to end of log file.
CDRAPPEND()
;Loop until 100 call records are collected
NUMOFRECORDS = 0
While NUMOFRECORDS < 100
Waitfor &quot;^M&quot; Forever
NUMOFRECORDS = NUMOFRECORDS + 1
StatMsg &quot;%d Lines collected to buffer.&quot; NUMOFRECORDS
Endwhile
Strcpy CDRSTATUS &quot;Emptying Buffer file &quot;
Strcat CDRSTATUS BUFFERNOW
Dlgupdate 0 1
;After 100 Call records, switch buffer files
Goto Goagain
ENDPROC
;**********************************************
PROC DATESTAMP
integer MONTH, DAY , YEAR, HOUR, MIN, SEC
String TWODIGDAY = &quot;0&quot; ; ADDS THE ZERO AT WHERE A 1 DIGIT DAY OCCURS.
String THISMONTH, THISDAY, THISYEAR, TWODIGMONTH, TWODIGYEAR
ltimeints $LTIME YEAR MONTH DAY HOUR MIN SEC ;INTEGER DATE VALUES.
Strset TODAY 0 0 255
Strcpy TODAY $DATE
Numtostr MONTH THISMONTH ; CONVERT TO STRING VALUES.
NumtoStr DAY THISDAY
NumtoStr YEAR TWODIGYEAR ; COLLECT 2 DIGIT YEAR STRING.
StrCat TWODIGMONTH THISMONTH ; ADDS STRING VALUE FOR 2 DIGIT CONVERSION.
Strcat TWODIGDAY THISDAY
Strset THISMONTH 0 0 255 ; RESETS STRING THAT WAS USED TO ADD VALUE
Strset THISDAY 0 0 255
Strright THISMONTH TWODIGMONTH 2 ; COPIES LAST TWO DIGITS BACK TO STRING
Strright THISDAY TWODIGDAY 2
Strright THISYEAR TWODIGYEAR 2 ;COPIES LAST TWO DIGITS OF YEAR.

; SAVE AS STRING DATEFNAME
Strcpy DATEFNAME THISYEAR
Strcat DATEFNAME THISMONTH
Strcat DATEFNAME THISDAY
;Now the string datefname = &quot;yymmdd&quot;
ENDPROC
;****************************************
PROC BUFFERSETUP
;Check for availability of buffer file
String BUFFER1 = &quot;buffer1.cap&quot;, BUFFER2 = &quot;buffer2.cap&quot;
Set Capture query OFF
Set Capture Overwrite ON
Fetch Capture file BUFFERNOW
If Strfind BUFFERNOW BUFFER1
Set Capture file BUFFER2
Else
Set Capture file BUFFER1
Endif
;Reset Capture to buffer file
ENDPROC
;*************************************
PROC CDRAPPEND
String CDRLOGFILE, LOGNUMBER, OUTPUT, INPUT, CDRDATA
Integer FILEINDEX = 10
Long CDRLENGTH
While 1
NumtoStr FILEINDEX LOGNUMBER
Strcpy CDRLOGFILE DATEFNAME
Strcat CDRLOGFILE LOGNUMBER
Strcat CDRLOGFILE &quot;.cdr&quot;
If ISFILE CDRLOGFILE
Fopen 1 CDRLOGFILE Read
Flength 1 CDRLENGTH
If CDRLENGTH < 5000000
Fclose 1
ExitWhile
Endif
Else
Exitwhile
Endif
FILEINDEX = FILEINDEX + 1
Fclose 1
Endwhile
Fetch Capture Path CDRDATA
Addfilename CDRDATA BUFFERNOW
If IsFile CDRDATA
; Fileview CDRDATA
FOpen 0 CDRDATA ReadWrite
Fopen 1 CDRLOGFILE Readappend
While Not Feof 0
FGets 0 OUTPUT
IF Strfind OUTPUT &quot;0&quot;
FPuts 1 OUTPUT
Endif
Endwhile
Fseek 0 0 0
Ftruncate 0
Fclose 0
Fclose 1
Strcpy CDRSTATUS &quot;Data Logged to &quot;
Strcat CDRSTATUS CDRLOGFILE
Dlgupdate 0 1
;FILEVIEW CDRLOGFILE
Else
Strcpy CDRSTATUS &quot;Capture file &quot;
Strcat CDRSTATUS BUFFERNOW
Strcat CDRSTATUS &quot; not found. Creating new buffer file&quot;
Dlgupdate 0 1
Endif
Endproc
;*****************************
PROC CLEARCAPTURE
Capture OFF
CDRAPPEND()
Set Capture File None
Strcpy CDRSTATUS &quot;CDR Capture stopped&quot;
Dlgupdate 0 1
Pause 1
Exit
ENDPROC
;***********************************************[/tt] Robert Harris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top