I have a problem related to expect.
when i run abc.sh which includes following lines
#!/usr/bin/expect
spawn scp /etc/httpd/conf/httpd.conf 192.168.0.12:/tmp
######################
expect {
-re "password:" {
exp_send "PASSWORD\r"
}
}
interact
its works fine
but when i use similar code in my running script it doesnt work
#!/bin/bash
clear
while read -u3 LINE
do
code .........
code .......
code ........
REMOTE_COMMANDS1="scp -r -v $BASE_DIRECTORY/$USERNAME $D_IPADDRESS:/home/"
spawn $REMOTE_COMMANDS1
######################
expect {
-re "password:" {
exp_send "redhat\r"
}
}
interact
done 3< /opt/sitelist.txt
it gives error
./script.sh: line 62: syntax error near unexpected token }'
./script.sh: line 62:}'
i think it is due to the fact that i am not including #!/usr/bin/expect in top of the script but if i use this and execute my script it doesnt do any thing and display all of code in terminal after excution. so can we include #!/usr/bin/expect and #!/bin/bash simultaneously ?
Regards, Aditya