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!

Capturing data, filename part of trigger string?

Status
Not open for further replies.

tedzap

Programmer
Aug 12, 2006
31
US
Hello,

I'm new to ASPECT programming, although I have used PROCOMM as my Telnet client for years. I think ASPECT may be able to do what I want, but am having difficulty getting started. I was very glad to come across this site!

I would like to send a trigger (string?) from the host which will signal the ASPECT script to turn on data capture. Another (different) trigger can be sent when the capture should be turned off.

I would either like to prompt for a capture file name, or better, have the file name embedded in the trigger string.

I have control of the trigger being sent from the host, but it may be as simple as:

TRIGGER filename.cap

then

ENDTRIGGER

Does this sound plausible?

 
Look into using When.

There's a small example of it on the following thread:

thread448-961482
 
As kodr mentioned, you'll want to use the when command, specifically the when target format to call a procedure when the trigger is received to start the capture and another procedured to close the capture when the second trigger is received.

Probably the easiest way to set the capture file name would be to send the filename after the trigger and have the procedure use the rget command to grab the name. If you send a carriage return/linefeed after the filename, the rget command will end when it hits that and the string from the rget command will hold only the filename. One thing to keep in mind with rget is that the data it grabs will not appear on-screen.

Once you have the filename in the string, you would use set capture file strvar to set the capture file name, where strvar is the name of the string variable containing the filename. Capture on will turn on the capture string and capture off to close it.

 
Thanks kodr and knob, great stuff!

Just the kind of info I was looking for.
 
I have made some progress, but appear to be misusing some of the commands.

What it is supposed to do:
In words, my script is to trigger off of a certain text string, then grab (using RGET) the next string and use it for a capture file name. Then it turns on the capture and grabs a page. Another unique string tells it to turn off the capture process.

What it is doing:
The script sees the trigger and then appears to grab the file name string with RGET (I think it is happy because the string stopped being echoed to my screen once I added the rget command). Then it turns on the capture file and grabs the appropriate stuff.

The problems are:
1. it is using the default capture file name instead of the string picked up by RGET.

The string that follows "PO CAPTURE ON" is "12345.txt". In other words, the host is sending:

PO CAPTURE ON12345.txt


2. the capture file has some garbage (to me) inserted at the beginning of the capture. This is the garbage as visualized in notepad: 





Here is the script:
proc main
when target 0 "PO CAPTURE ON" call get_fname_and_capture

while 1
yield
endwhile
endproc

proc get_fname_and_capture
string file_name
rget file_name
set capture file file_name
capture on
waitfor "Signature: ____________________"
capture off
endproc



Anyone see my errors?

Thanks,
-Ted
 
My guess on the garbage is that it is an escape sequence sent by the remote system. You can verify that by using Procomm's monitor window and looking at the data sent across. Here is some information on it copied from my site:

Procomm's Monitor Window can be used to view the incoming and outgoing data, in both hex and ASCII format. To activate this window, select the Data | Monitor Window menu item. Resize the Monitor Window so that you can view the entire width of the window, then click back in the Procomm Plus window so that the Monitor Window does not have focus. Incoming text is displayed in red, while text you send is colored blue. The Monitor Window can be handy for viewing incoming escape sequences (to determine if Procomm Plus is responding properly to them) or to verify that the program is sending the data you think it should be.

If I'm correct about the escape sequences being sent, then your capture file is probably not using the desired name due to invalid characters (the escape sequences) being in the string.

 
Yes, I think that you are right, the garbage appears to be transmitted from the host. Here is what the monitor shows:

PO CAPTURE ON12345.TXT

followed by the "good" text I wish to capture. short of trying to change what the host is sending, can you see a good way to grab the correct file name and disregard this (apparently) repeatable stuff that I don't want?

 
hmmm. any way to set this string as the the RGETCHAR and strip it?
 
I found a workaround that "skips over" the unneeded characters by doing second rget into a junk variable.

Below is the current script, If anyone has any advice about making it better I would appreciate the input.

I think that I will see if I can get it to generate an email with the file attached to it using mapisend. my first attempt does not work. shock.

thanks for the help!


proc main
when target 0 "PO CAPTURE ON" call get_fname_and_capture

while 1
yield ; puts it in a continuous loop
endwhile
endproc

proc get_fname_and_capture
string file_name
string junkdump
set aspect rgetchar 90 STRIP ; rget end character to Z
rget file_name ; picks uf the filename
set aspect rgetchar 32 STRIP ; rget end char to "space"
rget junkdump ; reads in junk chars
set capture file file_name ; renames capture file
capture on ; starts the data capture
waitfor "Signature: ____________________" ; till complete
capture off ; turns off data capture
set aspect rgetchar 13 STRIP ; resets rget end character
endproc

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top