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!

Procomm variable assignment issue

Status
Not open for further replies.
Mar 8, 2006
3
US
Hi,

I'm currently working on an Aspect script that will search a switch for a mac address that the user inputs. I have to use the information displayed when the code "show bridge port 1-24" is executed. This code displays a list of mac addresses on the Procomm terminal. However, I'm having trouble assigning this information to a variable so that I can use it to compare to user input. I know there should be an easy way to do this but after two days of searching through the help menu I have come up with nothing of much use. Since I am new to this scripting language I need all the help I can get. I really appreciate anything you could give me.
 
Is the problem you need to find a way to get the information from the screen into your script so the data can be used? If so, I usually find it easiest to save the data either to a capture file or use the snapshot command (if the data all fits on one screen) and open that text file using the fopen command. Assuming the data comes across in a structured format that is consistent, you could use the strfind command to look for a header or other constant string to make sure you have the right line and/or starting point. You could then use commands like substr, strtok, or strextract to grab the particular piece of data you need.

 
Thanks for the help. :) I thought I was going to have to go that route. I have been doing some research through the help menu and finally came across the fopen just before you posted. I have got the script to write the file and to open it. Now what I need to do is take user input which I would do through the sdlginput for the mac address and assign that input to a variable. Is the information from the capture saved to a variable as well? If so, how do I reference it? If not, how do I use the strfind command in this situation? The main part of my script is posted below for reference.

String Fname="C:\Program Files\Procomm Plus\Capture\Bridge_Data.cap", notopened
proc main
waitfor ">"
transmit "sh br port 1-24 ^M"
waitfor ">"
sbsave File "C:\Program Files\Procomm Plus\Capture\Bridge_Data.cap"

if fopen 0 Fname READ TEXT
(Bridge_Data info = user input;
display data string)

else
errormsg "File not Open" "not Opened" notopened
endif
 
No, you would need to read the data line by line from the capture file like this:

if fopen 0 Fname READ TEXT
while not feof 0
fgets 0 sLine
endwhile
etc. etc.

The fgets command will read a line of data from the capture file into the sLine string variable.

 
Thanks knob you have been a big help. I finally got a chance to sit down and finish the script. It is attached below if someone would like to use it in the future.

;*********************************************************
String Fname="C:\Program Files\Procomm Plus\Capture\Bridge_Data.cap", sLine, Mac_Address
Integer nItem=0
proc main
transmit "sh br port 1-24 ^M" ;display bridge table
waitfor ">"
sdlginput "Mac Input" "What is the Mac Address:" Mac_Address ;user input to search for given Mac Address

set capture file Fname ;set where capture file goes

if fopen 0 Fname READ TEXT ;if Fname is open read text
capture on ;start capture
while not feof 0 ;while data is in file
fgets 0 sLine ;get next line in bridge table
if strfind sLine Mac_Address ;find mac address in sLine
usermsg sLine ;show sLine
endif

endwhile


endif
capture off
endproc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top