cancel
Showing results for 
Search instead for 
Did you mean: 

use ftp to move file

heaman1
Regular Advisor

use ftp to move file

I use ftp to access the remote server , everything works fine , but I would like to ask can I move the file in the ftp server to another directory ( just like "mv myfile temp" - move myfile to temp directory in linux ) , I read thought the man page , but could not find it , can advise what can i do ? thx
9 REPLIES
Bill Hassell
Honored Contributor

Re: use ftp to move file

The command is rename, not mv. ftp is a multi-OS tool so the commands are specific to ftp. Note also that the actual commands that work depend not only on the client but also the destination. Use the ? command in an ftp session to see what is available.


Bill Hassell, sysadmin
heaman1
Regular Advisor

Re: use ftp to move file

the reply ,

I read ? but not found move , mv command , the rename is not change the file name , I really want to move the file to backup directory in remote server not just rename , can ftp do it ? thx
Shankar_6
Regular Advisor

Re: use ftp to move file

Hi,

I remember sftp have options to rename the file from old path to newpath

Shankar
Suraj K Sankari
Honored Contributor

Re: use ftp to move file

Hi,
You can used cd and lcd
cd for remote directiory and
lcd for local directiory.
then move the desire file to remote location and delete the file with delete command.

Suraj
heaman1
Regular Advisor

Re: use ftp to move file

thx Suraj K Sankari ,

you said "then move the ..." , how to move , can advise what command that I can use ? thx
Ganesan R
Honored Contributor

Re: use ftp to move file

Hi Heaman1,

Fortunately move command is not available on ftp. Indeed rename is doing the same function. I assume that you are getting a file called test.txt from remote server through ftp and want to move to backup directory after fetching the file.

You just need to add this lines in your script after copying the files.

#--------------------------------------------
# Move and Rename the file on remote server # after copying
#--------------------------------------------
ftp <<**
open abc.company.com
rename test.txt /tmp/test.txt.`date +'%d%b%y`bye
**

This will remove the source file and move to /tmp directory as test.txt.27Apr09

Instead of /tmp, I would suggest you to create a backup directory on user home directory(or somewhere) and move over there.

rename test.txt ./backup/test.txt.`date +'%d%b%y`
Best wishes,

Ganesh.
Ganesan R
Honored Contributor

Re: use ftp to move file

Hi Again,

Typo error on my previous post. Script should be like this.

#--------------------------------------------
# Move and Rename the file on remote server after copying
#--------------------------------------------
ftp <<**
open abc.company.com
rename test.txt /tmp/test.txt.`date +'%d%b%y`
bye
**

Sincere apolosize for the mistake.
Best wishes,

Ganesh.
heaman1
Regular Advisor

Re: use ftp to move file

thx reply ,

I tried it , but pop error

350 Ready for RNTO.
550 Rename failed.


can advise what is wrong ? thx
heaman1
Regular Advisor

Re: use ftp to move file

the all ,

this is permission problem , i got it already , thx for your help .