• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2059
  • Last Modified:

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???
0
ritru
Asked:
ritru
1 Solution
 
akumanovaCommented:
Don't quite understand what you are talking about, please re-write your question in detail.
0
 
aim4fameCommented:
doing this in shell?

if {$variable} {
   ...
}
0
 
kaosouCommented:
define expect script .. please
what programming are you are doing  ?
what language is the script ?
0
 
ritruAuthor Commented:
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...
0
 
aim4fameCommented:
I'm not sure if that's possible - I thought the purpose of an expect script was to run re-occurring commands for you in the background.

otherwise could you not use if in the syntax I posted earlier?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now