I want to move all files in local directory to remote directory.
And I am using this code to achieve it
SOURCE_FILE=/var/www/oneserver/*
TARGET_DIR=/var/www/anotherServer
ARCHIEVEFILE=/var/www/archieveServer
/usr/bin/expect<<EOD
spawn /usr/bin/sftp -o Port=$PORT $USER@$HOST
expect "password:"
send "$PASSWORD\r"
expect "sftp>"
send "put $SOURCE_FILE $TARGET_DIR\r"
expect "sftp>"
send "bye\r"
EOD
It works fine, but sometime it stops and only send some files.
I also want to move the already sent file to ARCHIEVEFILE by using mv command. But don't get idea how to move it. I can't use SCP because the remote server not allowed using basic port, and the only way is using SFTP.
the
$ARCHIEVEFILEis still the local server, just to backup/move so those files are not sent anymore with next cronjobthe
TARGET_DIRis the remote server.
Can anybody help, please?
$ARCHIEVEFILEis still the local server, just to backup/move so those files are not sent anymore with next cronjob. – Al Kasih Apr 19 '18 at 07:34TARGET_DIRis the remote server. – Al Kasih Apr 19 '18 at 07:35for filename in ...with the script I have right nowsend "put $SOURCE_FILE $TARGET_DIR\r". As far as I know you usecpmethod, while I usedputandexpectmethod. – Al Kasih Apr 19 '18 at 08:39sshfs. – Kamil Maciorowski Apr 19 '18 at 08:41man 1 sshfsis your friend. – Kamil Maciorowski Apr 19 '18 at 08:59to mountis. hehe This is returning bad mount pointsshfs -p $port $user@$host:/ "/my/local/files/in/dir/ /remote/dir/to/transfer"– Al Kasih Apr 19 '18 at 09:18sshfs user@host:dir mountpoint, e.g.sshfs klaudia@server:/home/klaudia/ "/local mountpoint/that has to exist beforehand/". – Kamil Maciorowski Apr 19 '18 at 09:25Transport endpoint is not connected– Al Kasih Apr 19 '18 at 09:30