There is a way to do very easily.
You need to install 'expect' command.
"expect" command is simply expecting a text from terminal, and send it when it meets expectation.
sudo apt-get install expectInstallation is done.
Sample usage.
Let's make simple shell program
vi abc.sh
Type into shell shell program.
#!/usr/bin/expect -f set timeout 100 spawn ssh userid@servername expect "/home/devtrigger/.ssh/id_rsa" send "password\r" expect "servername:" send "bash\r" interactyou should not omit first line "#!/usr/bin/expect -f" it indicate that it will run by expect.
you can ommit "timeout 100" which is waiting for response from server. I used the timeout option for using long process like copy a big file from ftp or etc.
of course, you need to replace certain text like "devtrigger", "password"
save it.
let's make the file executable and run it
chmod 755 abc.sh ./abc.sh
No comments:
Post a Comment