# Ftp files with date

**URL:** <https://community.unix.com/t/ftp-files-with-date/330595>\
**Category:** Shell Programming and Scripting\
**Created:** [June 16, 2013, 9:10am UTC](https://community.unix.com/t/ftp-files-with-date/330595 "2013-06-16T09:10:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Simanto](https://community.unix.com/letter_avatar/simanto/32/5_5575768a8748004e209b776fc1b2916d.png) [@Simanto](https://community.unix.com/u/Simanto)\
**Post date:** [June 16, 2013, 9:10am UTC](https://community.unix.com/t/ftp-files-with-date/330595/1 "2013-06-16T09:10:39Z")

</div>

Hi,  
i need to put files with current date at end from one server to another.  
i.e. all the output files from below comand.

```nohighlight
ls -ltr `date '+monthly_stats.sh%y%m%d'`

```

am using

```nohighlight
mput `date '+monthly_stats.sh%y%m%d'`

```

but no files are transfered

```nohighlight
Connected to gbdsnh18.hartfordlife.com.
220 gbdsnh18 FTP server ready.
331 Password required for tc20022.
230 User tc20022 logged in.
200 Type set to I.
250 CWD command successful.
Local directory now /nas/gbd_appdba/gbdsnh19
221-You have transferred 0 bytes in 0 files.
221-Total traffic for this session was 289 bytes in 0 transfers.
221-Thank you for using the FTP service on gbdsnh18.
221 Goodbye.

```

can someone please help me with this.

Thanks  
sim

---

<div class="post-metadata">

**Author:** ![Just\_Ice](https://community.unix.com/user_avatar/community.unix.com/just_ice/32/165_2.png) [@Just\_Ice](https://community.unix.com/u/Just_Ice)\
**Post date:** [June 16, 2013, 12:25pm UTC](https://community.unix.com/t/ftp-files-with-date/330595/2 "2013-06-16T12:25:51Z")

</div>

ftp, afaik, has a very limited command set that you can use ... try running the mput command with "mput monthly\_stats.shYYMMDD" instead ...

---

<div class="post-metadata">

**Author:** ![bakunin](https://community.unix.com/letter_avatar/bakunin/32/5_5575768a8748004e209b776fc1b2916d.png) [@bakunin](https://community.unix.com/u/bakunin)\
**Post date:** [June 16, 2013, 2:49pm UTC](https://community.unix.com/t/ftp-files-with-date/330595/3 "2013-06-16T14:49:52Z")

</div>

Just Ice is correct: yes, there are commands like "ls" or "cd" inside "ftp", but these are not UNIX-commands at all. These are just subcommands inside "ftp". "ftp" is not just another shell, but an application program.

If you want to send a list of files which is more complicatedly constructed than via a single file glob (something like "mput \*txt") you will have to preapre a list before and then use "ftp" inside a loop to transfer the files one by one. Another possibility is to prepare a command list for ftp and then use this document as input to ftp.

Still, i think you should forget ftp altogether and use some other tool, namely "scp". This is scriptable, it doesn't require you to put passwords inside scripts and it doesn't transmit passwords or files unencrypted over the network. "ftp" should NOT be used in any network environment any more.

I hope this helps.

bakunin

---

<div class="post-metadata">

**Author:** ![siddhanta](https://community.unix.com/letter_avatar/siddhanta/32/5_5575768a8748004e209b776fc1b2916d.png) [@siddhanta](https://community.unix.com/u/siddhanta)\
**Post date:** [June 16, 2013, 4:08pm UTC](https://community.unix.com/t/ftp-files-with-date/330595/4 "2013-06-16T16:08:09Z")

</div>

thanks for reply!

i tried the second option to use for loop and send filename one by one but it din work.

```plaintext
for i in `cat /nas/gbd_appdba/gbdsnh19/files'
mput i
done

```

I get the below output

Connected to [gbdsnh18.hartfordlife.com](http://gbdsnh18.hartfordlife.com).  
220 gbdsnh18 FTP server ready.  
331 Password required for tc20022.  
230 User tc20022 logged in.  
200 Type set to I.  
250 CWD command successful.  
Local directory now /nas/gbd\_appdba/gbdsnh19  
We only support non-print format, sorry.  
i: No such file or directory  
?Invalid command  
221-You have transferred 0 bytes in 0 files.  
221-Total traffic for this session was 289 bytes in 0 transfers.  
221-Thank you for using the FTP service on gbdsnh18.  
221 Goodbye.

can you please give me a example to use scp in such case. i will give a try for that.

Regards  
Sid

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/5_5575768a8748004e209b776fc1b2916d.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [June 16, 2013, 4:40pm UTC](https://community.unix.com/t/ftp-files-with-date/330595/5 "2013-06-16T16:40:44Z")

</div>

Please read the above posts to understand why you don't have loops in ftp. Wishful thinking will not make them be wrong.

Also, please use one account, not an army of sockpuppets.

---

<div class="post-metadata">

**Author:** ![siddhanta](https://community.unix.com/letter_avatar/siddhanta/32/5_5575768a8748004e209b776fc1b2916d.png) [@siddhanta](https://community.unix.com/u/siddhanta)\
**Post date:** [June 16, 2013, 4:48pm UTC](https://community.unix.com/t/ftp-files-with-date/330595/6 "2013-06-16T16:48:23Z")

</div>

OK.  
So to make this work I need to call ftp inside a for loop. Something like below

Ftp.sh  
For I in ` cat files  
Ftp  
Mput  
Done

Sorry am not in front of my lappy so just writing the logical code.

Please lenme know if an correct.
