Hi All,
I am trying to create a script with the help of while and expect loop to do the following:
- script will pick up the servers one by one from server_list file and will do ssh to it.
- for each server it will change the password of user test1.
- script should also provide logs for each and every step
below is sample script which i have created (doesnot inlcude the password change part , since i want to first make sure script run correctly before inclusding password change commmand in to it).
cat -n test.sh
1 #!/usr/bin/expect -f
set hosts [open server_list r]
4 while {[gets $hosts host] >= 0}
5 {
6 #echo "connecting $server via ssh"
7 spawn sh -p 56786 -l test1 $host
8 expect "$"
9 send "exit\r"
10 expect eof
11 }
12 close $hosts
i am getting error as :
[root@VM172016001140 tmp]# bash -x test.sh
+ LOG=/tmp/changepassword.log
+ set hosts '[open' server_list 'r]'
test.sh: line 13: syntax error: unexpected end of file
can someone help in modifying this script to fulfill all the mentioned requirement.