LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   FTP renaming (https://www.linuxquestions.org/questions/linux-newbie-8/ftp-renaming-936870/)

Biomouse 03-28-2012 07:38 AM

FTP renaming
 
Is there a way that when you ftp it uses a temporary name until the upload/download is complete and then only renaming it to the correct filename
like the way a zip file is called zi..... till the zip is complete.

colucix 03-28-2012 10:53 AM

Yes. Using the plain ftp command you can do something like this:
Code:

#!/bin/bash
#
file=testfile
ftp -n ftp.hostname << EOF
  user username password
  put $file .$file
  rename .$file $file
  bye
EOF

Despite the fact it is unsafe to keep a password in clear text inside a script, this is just to show you that you can upload a file with a different name by adding a second argument to the put command. Then you can simply use the rename command to change it back to the original name. In my example the put command just adds a leading dot to the file name to make it hidden (unless the ftp server has an alias to show hidden files by default).


All times are GMT -5. The time now is 05:53 PM.