I'm working on a shell script and I'm trying to send a backup file to a sftp server :
remotepath=/backup/
expect -c "
spawn sftp [email protected]
expect "password:"
send "password123\r"
expect "sftp>"
send "put /back_up/bkp_2022.tar.gz $remotepath\r"
expect "sftp>"
send "bye\r"
"
And this is the output that I get without the file being transfer - It just creates "?send put" and "?send byer?".
-rw-r-----. 1 admin admin 1267 Aug 17 11:14 script.sh
-rw-r-----. 1 admin admin 0 Aug 17 11:15 ?send put
-rw-r-----. 1 admin admin 167 Aug 17 11:15 ?send byer?
Can you please help ?
scpinstead ofsftp?set timeout -1to the top of the expect code.