Reputation: 53
I tried including a mv command with ftp command, in a script file. But when i run that script file, it fails on the mv command.
Code:
/usr/bin/ftp -i -n $HOST <<END_FTP
quote USER $USER
quote PASS $PASSWD
cd /home/infodba/temploc/test_script/
binary
mget Cust*.txt
mv Cust*.txt ./archive
quit
END_FTP
exit 0
It throws this error: "?Invalid command"
The same script works if i remove the mv command from the file
Is there workaround?
Upvotes: 0
Views: 1705
Reputation: 1037
mv command is not supported by ftp/sftp (i.e) you can't move the files in the remote host, But with bang ( ! ) you will be able to execute the commands in your localhost.
After getting the files from remote host if you are trying to move files in localhost below works.
/usr/bin/ftp -i -n $HOST <<END_FTP
...
mget Cust*.txt
!mv Cust*.txt ./archive
...
...
END_FTP
Upvotes: 0
Reputation: 4015
mv
is not a valid ftp command. If you're trying to move the files you've just acquired to ./archive, you need to either exit ftp first, or escape the command with a !
.
!mv Cust*.txt ./archive
Upvotes: 1