Link to home
Start Free TrialLog in
Avatar of ritru
ritru

asked on

Expect script question(Nested if)

Hey, Gentlemen

I have an expect script for an application I'm trying to manipulate...Basically the expect script goes through the program and answers questions automatically, but when I want the script to stop when it doesn't know the answer it should give me a prompt to answer the question...

My question does an expect script have a nested if(if then else)in it's logic, if so what is it???
Avatar of akumanova
akumanova

Don't quite understand what you are talking about, please re-write your question in detail.
doing this in shell?

if {$variable} {
   ...
}
define expect script .. please
what programming are you are doing  ?
what language is the script ?
Avatar of ritru

ASKER

actually it's a unix based programming language called expect where for example you can do simple command line authoring
For this example I can telnet into the router and download the the configs..


for example:

#Telnet to the Ciscos
     spawn telnet $ciscohost
     expect {
           "word:"     {
               send "$password\r"
               expect ">" 
               send "enable\r$Enapwd\r"
               expect "#"
               send "term len 0\r"


               #Ok we're logged into the router
               #Now get the configuration
               set logfile "$logpath/cisco.$datestring/$ciscohost.$datestring.conf"
               log_file -noappend $logfile
               expect "#"
               send "wr t\r"
               expect "#"
               log_file
               send "\r"
               expect "#"
               #Now get the "show tech" information
               set logfile "$logpath/cisco.$datestring/$ciscohost.$datestring.tech"
               log_file -noappend $logfile
               send "show tech\r\r\r"
               expect "#"
               expect "#"
               log_file
               close
               wait
               }
          timeout {
               close
               wait
               }}
}                    
close $hostlist

The problem I'm having is I trying the run a program where it answers yes to all the questions and when it doesn't know the answer it should let the user answer it...sort of an if else statement...I don't know the syntax to use it in an expect script...
ASKER CERTIFIED SOLUTION
Avatar of aim4fame
aim4fame

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial