Ich schrieb ein Skript, um einen Ordner von VPS zu Synology NAS Server zu übertragen. Das Skript schlägt bei 1 oder 2% Übertragung fehl, ohne Angabe warum. Wenn ich den Befehl manuell ausführe, funktioniert es problemlos und es überträgt den Ordner einwandfrei. Ich bin mir nicht sicher, was das verursacht, und würde mich freuen, wenn ich eine Anleitung bekommen könnte, wo ich hinschauen soll.SFTP Manueller Befehl erfolgreich aber Skript schlägt bei 1 oder 2%
SCRIPT:
#!/usr/bin/expect
set dir [timestamp -format "%Y-%m-%d"]
spawn sftp [email protected]
expect "Password:"
send "passw0rd\n"
expect "sftp>"
send "cd /directory/\n"
expect "sftp>"
send "put -r /home/backup/$dir\n"
expect "sftp>"
send "bye\n"
ERGEBNIS:
[email protected] [/scripts]# ./sftp.sh
spawn sftp [email protected]
[email protected]'s password:
Connected to host.synology.me
sftp> cd /directory/for/backup
sftp> put -r /home/backup/2017-12-26
Uploading /home/backup/2017-12-26/ to /backup/2017-12-26
Entering /home/backup/2017-12-26/
Entering /home/backup/2017-12-26/accounts
/home/backup/2017-12-26/file1.tar.gz 2% 26MB 1.8MB/s 08:41 [email protected] [/scripts]#
[email protected] [/scripts]#
manuellen Befehl:
[email protected] [/scripts]# sftp [email protected]
[email protected]'s password:
Connected to host.synology.me.
sftp> cd directory
sftp> put -r /home/backup/2017-12-26
Uploading /home/backup/2017-12-26/ to /backups/2017-12-26
Entering /home/backup/2017-12-26/
Entering /home/backup/2017-12-26/accounts
/home/backup/2017-12-26/file.tar.gz 100% 959MB 820.2KB/s 19:57
/home/backup/2017-12-26/file2.tar.gz 100% 147MB 1.4MB/s 01:45
sftp> bye
[email protected] [/Scripts]#
warum immer '\ r'? '\ n' funktioniert möglicherweise nicht? –
Vielen Dank, Timeout wurde behoben. – Ali
@EmilyE. : '\ n' funktioniert immer noch, aber' \ n' wird intern in '\ 'umgewandelt. – Dinesh