A sample expect interactive script to SSH to a server , feed in a pre-configured username and password and execute a remote script.
#!/usr/bin/expect
log_user 0
set timeout -1
spawn ssh root@localhost /home/shareo/test.sh
expect "root@localhost's password:"
send "share1234\r"
log_user 1
expect "##END##"
Hope this is useful to some beginners.
#!/usr/bin/expect
log_user 0
set timeout -1
spawn ssh root@localhost /home/shareo/test.sh
expect "root@localhost's password:"
send "share1234\r"
log_user 1
expect "##END##"
Hope this is useful to some beginners.