Problems using EXPECT is a BASH shell script

0

This is the code (bash script):

echo "Pass for router:"
read -s pass


/usr/bin/expect <<EOD
spawn ssh 192.168.10.1 -l root 'opkg list-installed' > list-installed.txt
#echo @pass
expect "*password:*"
send "$pass\r"
interact
EOD

Problem is that it's returning nothing. It doesn't create the local file "list-installed.txt"

What could be wrong with this?

FernandoSBS

Posted 2013-11-17T15:14:06.107

Reputation: 1 541

Answers

5

Single quotes have no special meaning in expect. Use double quotes.

Additionally, use expect eof instead of interact, since there's nothing to actually interact with once you enter the password -- you're just waiting for the command to complete.

glenn jackman

Posted 2013-11-17T15:14:06.107

Reputation: 18 546

1+1 expect eof was the key for my situation. – FractalSpace – 2014-11-21T19:54:51.227