Could anybody please tell me why this is not working?
#!/bin/bash
cd /home
touch somefile
/usr/bin/expect<<FILETRANSFER
spawn scp -r -P remoteServerPort somefile remoteServerIP:/home
expect "assword:"
send "MyPassWord\r"
interact
FILETRANSFER
echo "It's done"
It doesn't give any error but file is not transferred to remote server.I have tried many ways still couldn't find any solution.
ssh(alsoscp). Read some ssh tutorial and use a public key./usr/bin/expect<<FILETRANSFER, here you are missing a space before<</usr/bin/expect -dand see what expect is doing.expect <<'FILETRANSFER'where the single quotes effectively quote the entire here-doc.