Tuesday, April 18, 2017

12.04 - execute local bash script in remote machine using expect

I have local shell script. Now, I want to run this local script in remote machine. Of course I can use ssh, but as it(the local shell script) should be like an automated one, it shouldn't ask for password to enter manually. So I used expect to eliminate that problem, so that if I run the script it wont ask password. And my script looks like below.




#!/usr/bin/expect
spawn ssh -o GSSAPIAuthentication=no root@10.3.0.39 'bash -s' < /path/to/localscript
expect -timeout 7 "*(yes/no)?" { send "yes\r";exp_continue }
expect -timeout 3 "*d: "
send "qbcrootpass\n"
interact


But it is not working. Please note, in my scenario, I don't want to use public key authentication.




Please help me to execute a local script in a remote machine using using expect.

No comments:

Post a Comment

11.10 - Can&#39;t boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...