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!

Evaluating output data with Aspect

Status
Not open for further replies.

majpooper

Technical User
Feb 5, 2005
17
US
I need to evaluate output data to the screen to help automate my procedure.

I have looked at the terminal commands to evaluate strings and integers but I am still not sure how to proceed.

In one case I will take the output that gives me a terminal ID (an integer from 1 to 24).

I want to capture the terminal number value so I can use it to invoke the next command to change the config of that terminal and later to change the terminal config back.

The output to Procom will look something like this:

User logged in on terminal #3

I then need to put the 3 in a command to re-config the terminal useing a comand something like this:

chg-term;term-3;logs-off

In the second case I will get line after line of cards with the status of each (maybe 60 or 100 lines or even more). I then want to only look at the cards that have a fault or are out of service. There could be several pages of cards (each card is just one line).

Example
command
card-stat;card;all
output
Card 102 blah balh blah In-Service
Card 103 blah balh blah fault
Card 104 blah balh blah Out-of-Sevice
Card 105 blah blahh blah In-Service
.
.
Card 613 blah balh blah fault
Card 614 blah blahh blah In-Service


For each card out of service or that has a fault status I need to execute a command as follows and then move on.
command
card-stat;card-102
output
card 102 blah
blah blah
blah blah
blah blah

I am not sure that the value will always be in the exact same col on the screen - but I think so. However the string will always be the same except in the case of the terninal the terminal # will be from 1 - 24.

Any ideas?



 
I usually find it easiest to work from a text representation of the screen (a capture file or snapshot) rather than trying to pull data directly from the screen buffer. In your case, since you are anticipating more lines than can be displayed on the screen, I would use a capture file. Once you have retrieved the entire data list, close the capture file, then open it using the fopen command with the READ and TEXT parameters. You will then want to read data line by line from the text file, checking each line using the strfind command for the presence of the fault string.

 
OK - makes sense for the cards.

How about the case for the terminal where it is always just on line of output - can you show me how that would look.
is termget on the right track?

Back to the cards - since I am going to be running a captue file during the whole entire process can I;
1) stop what I will call the "entire process" capture file
(which I know I can)
2) start a "card only" capture file (which I also know I
can)
3) evaluate the "card only" capture file (how? that's
where I am stuck)
4) append the "card only" capture file to the
"entire process" capture file (again how?)
5) start the new comand sequence for each card found with
a fault sending the output to the "entire process"
capture file (this is way over my ability as yet- so
any commands to use here would br a real help)

Does any of this make sense? or is it just too confusing?

Can you just rough out a few commands or a real rough script that I can start to play with - I just need to get an idea what commands to work with.

thx!
 
Yes, termgets would be the way to go to get one string of data. You would want to use waitfor or when target to detect when a common portion of the string (such as a prompt, fixed piece of text, etc.) appears on the screen, then you could use:

termgets $ROW 0 sLine

to read the entire value, where $ROW is an ASPECT system variable holding the value of the current row on the screen, and sLine is a string variable. This command would work only if the cursor is on the line with the text you want. If this is not the case, then you could subtract a line or two from $ROW as needed to make sure your script is reading the proper line of data from the screen.

I think I already addressed the "card only" capture file in my previous response (open capture file using fopen, read line by line using fgets, use strfind to find lines with the fault keyword), but let me know if it is still not clear.

To append to an existing capture file, probably the easiest way to do this is to issue a termreset command prior to sending the command needed to get the "card only" to clear the scrollback buffer. Then, once you have retrieved all of the data needed for that capture file, you can close it, reopen the "main" capture file, and issue a sbsave capture command to save the entire scrollback buffer to that overall capture file.

For item 5 in your list, I think you should just be able to pick up from where you left off by reopening your overall capture file, then reading line by line (like mentioned before) from the "card only" capture file, and send the necessary commands. Strfmt will likely be helpful to create the proper commands from a template.

 
Thanks Much ! knob - that is what I needed - someone to point me in the right direction - I'll let you know how it goes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top