call & execute the shell script within expect script
- by D.C.
#!/usr/bin/expect
spawn ssh derrick@$abc123.net
expect "password"
send "helloworld\n"
send "cd /tmp\n"
send "sh rename.sh\n" # this shell script will get a list of files and rename each file
send "exit\n"
expect eof
The problem is when 'rename.sh' started and within less than 3 seconds, the 'expect' script exits while 'rename.sh' is not yet done executed.
My question is how can I make my expect script to wait for the finish of 'rename.sh' execution?