I'm from local machine, ssh to remote machine, and sudo su to admin user. I don't wish to quit from ssh, I wish to stay on remote machine, so I tried:
$cat
#!/usr/bin/expect
spawn "/usr/bin/ssh myself@myremotebox -t \"/usr/bin/sudo su admin\""
expect "Password: " {send "mypassword\r"}
$./myssh.exp
spawn /usr/bin/ssh myself@myremotebox -t "/usr/bin/sudo su admin"
couldn't execute "/usr/bin/ssh myself@myremotebox -t "/usr/bin/sudo su admin"": no such file or directory
while executing
"spawn "/usr/bin/ssh myself@myremotebox -t \"/usr/bin/sudo su admin\"""
(file "./myssh.exp" line 2)
Seems I 've got syntax error. I tried to add/remove the "\" inside and outisde my spawn statement, neither works. How to fix it?
Thanks!
Should be:
spawn /usr/bin/ssh -t myself@myremotebox "/usr/bin/sudo su admin"
expect "Password: " { send "mypassword\r" }
interact