Pattern Matching in expect script
Hi,
I made a Expect - script to automate the process in communication Boxes. Login : User ID / Pwd and entering into the box is done but I stuck with the problem if once the pattern match then only next command will process. As an instance : below command will run in automatic manner after login into the box rtrv-crs-sts1::4-2-2:xyz; and then provide the output on prompt like below IP sk5829 SBTNVTDPFOMG 13-03-04 18:07:55 M SK5829 COMPLD "4-2-2,1-17:::," "4-2-2,2-17:::," I need to catch here 4-2-2,1-17:,4-2-2,2-17:in this manner so that in next command I can use them. Please suggest me how to catch both output. Thanks in advance. Thanks |
Do you want something like this?
Code:
~$ echo ""4-2-2,1-17:::," | awk 'BEGIN{FS=":"}; {print $1.FS}' Code:
VAL=$(<input> | awk 'BEGIN{FS=":"}; {print $1.FS}') Hope this will help, if I understood your requirement properly. |
Quote:
Pattern 4-2-2,1-17:::, and then use your suggested command. But In my problem I am into the live BOX and it is throughing out the output on shell rtrv-crs-sts1::4-2-2:xyz; and then provide the output on prompt like below IP sk5829 SBTNVTDPFOMG 13-03-04 18:07:55 M SK5829 COMPLD "4-2-2,1-17:::," "4-2-2,2-17:::," -------------- --------------- --more output on prompt. here in live action i need to catch the pattern "4-2-2,1-17:::,"and take into varaible. Thanks |
To be honest, your example isn't at all clear & leads to more confusion.
Which command you're running and how are you providing input to that command? Why you want to catch 4-2-2,1-17:::," and where this value will be used. Please make it little more clear. And can't you do like this? Code:
~# <input> | grep '4\-2\-2\,1\-17\:\:\:\,\"' |
Hi Shiva,
Let me more clear on my point. This script is to automate the Communication Box process. Here I need to login into the box from remote location with telnet via IP address. There are some certain set of commands which are needed to be through into the box one by one as per process.So in between this process when I am retrieving the logicals with automation by using command rtrv-crs-sts1::4-2-2:xyz; where <4-2-2> is provided input from comand line only. it provides the output IP sk5829 SBTNVTDPFOMG 13-03-04 18:07:55 M SK5829 COMPLD "4-2-2,1-17:::," "4-2-2,2-17:::," immidiately in second line i need to handle the output and use this for another command. I hope this may clear little bit. Hope for fruitfull result. Thanks |
You can save/redirect this output to some file, as:
Code:
rtrv-crs-sts1::4-2-2:xyz; > /tmp/outfile.txt But what sort of this box is and which OS? |
Yes shiva !!! this works for me....Thanks for the help...it is nice idea ...
|
Good. :)
BTW, you can Mark the thread as Solved, if you think it has so (option is under Thread Tools on top menu). |
All times are GMT -5. The time now is 11:57 PM. |