In my bash script file, I try to use expect
to provide password for ssh
command but it doesn't work. Here is my script:
#!/bin/bash
/usr/bin/expect << EOD
spawn ssh root@192.168.1.201
expect "root@192.168.1.201's password:"
send "mypassword\r"
interact
expect eof
EOD
And the output after I execute the script:
[oracle@BTMVNSRV191 Desktop]$ ./login.sh
spawn ssh root@192.168.1.201
root@192.168.1.201's password: [oracle@BTMVNSRV191 Desktop]$
Could someone let me know, how to use expect
in my script without changing #!/bin/bash
to #!/usr/bin/expect
?