Expect looking for a loop of some kind.
- From: Michael Jensen (eto.NOSPAMdemerze@xxxxxxxxx)
- Date: Wed, 22 Nov 2006 00:32:45 -0600
About a year ago I was frustrated with have to manually check some
vpns every hour on the hour for cpu utilization. I did a little
research and found that expect was just the tool for going out and
interacting with command line interfaces, I bought the book and
created a small simple script that went out grabbed the data and
then it was parsed to a nice csv that could be looked at as needed
and eventually trended.
I have not done very much scripting since, but it seems now that
must make a very similar script except now I must make it available
for other people to use, I am trying to make an if statement or
while statement or a loop of some kind so that it will continue
until the all the choices are false.
Thank you in advance and sorry for the newbie question I?m sure once
I see an example it will seem obvious but right now I just can?t
figure it out.
Mike
#!/usr/bin/expect -f
#spawn ssh and put down what will come back
spawn ssh user@somevpn
# Here is where I would like a loop
# I have tried This :
#expect ?yes? { send ?yes\n? } \
# ?assword: ?{ send ?password?
#because there will be many new sites I need the rsa yes
#this works well as an OR statement I would like to
#know how have it the if statement till none of the above are true
#then go on to the next line or process
expect "user@somevpn's password:"
send "password\r"
# I am starting and stopping the logs to different files for
different reports
log_file -a /SCRIPTS/vpn/temp/sa_active.log
expect ">"
send "get sa active\r"
#this is another place where I would like to place a loop where it
#would repeat until it was false
#as this is a variable number of ?pages?
expect "\\--- more ---"
send "q"
log_file
sleep 1
expect ">"
log_file -a /SCRIPTS/vpn/temp/logevent.log
send "get log event | inc ocsp\r"
send "\r"
log_file
log_file -a /SCRIPTS/vpn/temp/e3.log
send "get int e3/1 screen\r"
expect "\\--- more ---"
send "\r"
expect "\\--- more ---"
send "\r"
log_file
expect ">"
log_file -a /SCRIPTS/vpn/temp/xauth.log
send "get xauth act\r"
expect "\\--- more ---"
send "\r"
expect "\\--- more ---"
log_file
send "\r"
send "q"
sleep 1
expect ">"
send "exit/r"
.
- Follow-Ups:
- Re: Expect looking for a loop of some kind.
- From: Glenn Jackman
- Re: Expect looking for a loop of some kind.
- Prev by Date: Re: Finding a niche for Tcl
- Next by Date: Re: Finding a niche for Tcl
- Previous by thread: Amazon S3 in Tcl
- Next by thread: Re: Expect looking for a loop of some kind.
- Index(es):
Relevant Pages
|