expect complains that send: spawn id exp6 not open
Notice the "Connection closed by foreign host."
spawn telnet 192.168.1.51 -l root
expect {
"Connection closed by foreign host." {
puts "Telnet session closed unexpectedly."
puts "Please try again."
exit
}
"#"
}
With this form of the expect
command, expect is looking for two patterns, and the first one found "wins".
- if "connection closed" happens, the messages are printed and the program ends
- if "#" (your prompt) shows up, there's no specific action, so the
expect
command returns and the rest of your program can carry on
This technique is essential for efficient expect programming where you frequently have to look for multiple patterns.
Looking forward, you might expect to see "Connection closed" at any time: investigate the expect_before
command.
getting send: spawn id exp6 not open error
Seperate out echo itsme | sudo -S lvremove #{snap_name}
try this
`/usr/bin/expect <<delim
exp_internal 0
set timeout 20
spawn sudo lvremove #{snap_name}
send "itsme\r"
expect {Do you really want to remove active logical volume #{name}? [y/n]:}
send "y\r"
expect eof
delim`
Expect script error send: spawn id exp4 not open while executing send password
I have already fix it, it was an error in dos2unix command. I had to code it again over Ubuntu for avoiding to run dos2unix command.
Related Topics
Using Sftp to Transfer Images from HTML Form to Remote Linux Server Using Perl/Cgi.Pm
Invalid Choice: 'Kernel_Add_Dts' in Yocto Build
Linux Script Telnet Head Request
Cannot Find Module 'Firebase-Admin' When Trying to Deploy Firebase Functions
How to Reserve Ip When Provisioning Azure Vm (Resource Manager)
How to Make Sudo Save The Password
How to Install Vsftpd on Centos 6
Understanding Linux Display Variable
Bash Script Commands Not Working in Cron
Start Tomcat from Eclipse in Port 80 in Ubuntu with Authbind
Using Ebpf to Measure CPU Mode Switch Overhead Incured by Making System Call
Google Suggest Query Using Curl
Cannot Connect to The Docker Daemon at Unix:///Var/Run/Docker.Sock
Ftrace: System Crash When Changing Current_Tracer from Function_Graph via Echo