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 put term output into a varibal 1

Status
Not open for further replies.

majpooper

Technical User
Feb 5, 2005
17
US
So far I have writting pretty straight forward scripts.

But now I would like to get slick !

I want to transmit a command and based on it's output set some varibals (IP addresess and so on)and then use the info to transmit a new command.

Example
transmit ^A get-info ^M

the output to the terminal would be:
INFO
IPADDR SPEED ROUTE
192.168.1.11 10 12.10.223.89

transmit ^A set-info;ip=
transmit IP;
transmit speed=
transmit SPEED; ^M

I want to do a snapshot or termget to capture the info then put them into varibals so I can then use the varibals as input to transmit a different command.

A couple of things are that I always know where the Varibal data will begin but not end i.e 10.1.1.1 vs 192.168.255.255
and I am not sure how to go get the data and then put the data into a varibal.



 
There are a couple different ways I see to do this. Is the data always on the same column for the different fields, or does that vary.

If the columns are always the same, you could use the substr command starting at the beginning column position to get that information and everything up to the starting column of the next field. You could then use strreplace sVar " " "" to strip out the trailing spaces.

If the columns don't always line up, you could use strextract to get the first piece of data, then use substr to get everything to the left of that string. You would want to delete the leading spaces from that string (I'm pretty sure I have a sample function on my site that flips the string, deletes the now-trailing spaces, reflips, and returns the string), then use strextract to get that second value, and so on.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top