GoneHiking
Technical User
Hello, I have a script that logs into a cisco switch, sends the info to a logfile, then logs out. What I then need to happen is to have the script "call" a separate file that is nothing more than a series of grep commands (all contained in a file that is set as an executable). My problem is that once the expect script ends and I tell it to log out of the switch, it won't run the second file.
I can run the two independently (i.e. I run the expect script to pull the data and store it in a file, then manually run the second file) and it works fine. I just can figure out a way to run the expect script AND run the other file using just the expect script.
Here's the expect script:
#!/usr/local/bin/expect --
log_file -noappend 1924log
spawn telnet $argv
expect -nocase "password:"
send "password\r"
send "s"
send "x"
send "n"
send "i"
send "x"
send "x"
send "f"
send "x"
send "x"
send "y\r"
send [exec mdso]
interact
===============
Here is the contents of the file named "mdso"
clear
cat 1924log | grep -i "Model Number:" | cut -c 24-40
cat 1924log | grep -i "name of system" | cut -c 54-80
cat 1924log | grep -i "\[I\] IP address" | cut -c 50-70
cat 1924log | grep -i "\[S\] Subnet mask" | cut -c 50-70
cat 1924log | grep -i "\[G\] Default gateway" | cut -c 50-70
cat 1924log | grep -i ": Standard Edition" | cut -c 6-13
======
Any ideas on how to make the expect script also run the second file (named "mdso")? Is there a way to "jump to the shell" while running an expect script so that I can execute another command, then return to the expect script?
Thanks,
Andy
I can run the two independently (i.e. I run the expect script to pull the data and store it in a file, then manually run the second file) and it works fine. I just can figure out a way to run the expect script AND run the other file using just the expect script.
Here's the expect script:
#!/usr/local/bin/expect --
log_file -noappend 1924log
spawn telnet $argv
expect -nocase "password:"
send "password\r"
send "s"
send "x"
send "n"
send "i"
send "x"
send "x"
send "f"
send "x"
send "x"
send "y\r"
send [exec mdso]
interact
===============
Here is the contents of the file named "mdso"
clear
cat 1924log | grep -i "Model Number:" | cut -c 24-40
cat 1924log | grep -i "name of system" | cut -c 54-80
cat 1924log | grep -i "\[I\] IP address" | cut -c 50-70
cat 1924log | grep -i "\[S\] Subnet mask" | cut -c 50-70
cat 1924log | grep -i "\[G\] Default gateway" | cut -c 50-70
cat 1924log | grep -i ": Standard Edition" | cut -c 6-13
======
Any ideas on how to make the expect script also run the second file (named "mdso")? Is there a way to "jump to the shell" while running an expect script so that I can execute another command, then return to the expect script?
Thanks,
Andy