Need to login to multiple host I am unable to decide how can we add hostname variable in this script array or list. could any one suggest.
And the second thing is that i am getting error while executing this script.
#!/usr/bin/env expect
set timeout 12
set date [exec date "+%d-%B-%Y"]
spawn sh -c "cd /backup/"
for ((i=0;i<8;i++))
do
spawn sh -c "ssh host001n < ./backup.py > /backup/dbbackup-$file-$date.txt"
expect "Enter passphrase for key '/root/.ssh/id_rsa':"
send "pass\r"
expect "Enter passphrase for key '/root/.ssh/id_rsa':"
send "pass\r"
expect "Enter passphrase for key '/root/.ssh/id_rsa':"
send "pass\r"
expect "Password:"
send "pass\r"
interact
done
After adding only one shebang here is the below error.
spawn sh -c cd /backup/
wrong # args: should be "for start test next command"
while executing
"for ((i=0"
(file "./backup.py" line 14)
expect -f
)expect -f
.bash
(which explains the majority of the error messages - such asspawn: command not found
and so on)bash
construct inexpect
I think. For theTcl
/expect
equivalent, see for example wiki.tcl.tk/1015