Ftp files with date


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ftp files with date
# 1  
Old 06-16-2013
Ftp files with date

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.
Code:
ls -ltr `date '+monthly_stats.sh%y%m%d'`

am using
Code:
mput `date '+monthly_stats.sh%y%m%d'`

but no files are transfered

Code:
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

Last edited by Scott; 06-16-2013 at 10:47 AM.. Reason: Please use code tags
# 2  
Old 06-16-2013
ftp, afaik, has a very limited command set that you can use ... try running the mput command with "mput monthly_stats.shYYMMDD" instead ...
# 3  
Old 06-16-2013
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
# 4  
Old 06-16-2013
thanks for reply!

i tried the second option to use for loop and send filename one by one but it din work.
Code:
for i in `cat /nas/gbd_appdba/gbdsnh19/files'
mput i
done

I get the below output

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
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
# 5  
Old 06-16-2013
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.

Last edited by Corona688; 06-16-2013 at 05:51 PM..
# 6  
Old 06-16-2013
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to replace a parameter(variable) date value inside a text files daily with current date?

Hello All, we what we call a parameter file (.txt) where my application read dynamic values when the job is triggered, one of such values are below: abc.txt ------------------ line1 line2 line3 $$EDWS_DATE_INSERT=08-27-2019 line4 $$EDWS_PREV_DATE_INSERT=08-26-2019 I am trying to... (1 Reply)
Discussion started by: pradeepp
1 Replies

2. UNIX for Dummies Questions & Answers

Find the count of files by last created date based on the given date range

My unix version is IBM AIX Version 6.1 I tried google my requirement and found the below answer, find . -newermt “2012-06-15 08:13" ! -newermt “2012-06-15 18:20" But newer command is not working in AIX version 6.1 unix I have given my requirement below: Input: atr files: ... (1 Reply)
Discussion started by: yuvaa27
1 Replies

3. Shell Programming and Scripting

Shell script to compare two files of todays date and yesterday's date

hi all, How to compare two files whether they are same are not...? like i had my input files as 20141201_file.txt and 20141130_file2.txt how to compare the above files based on date .. like todays file and yesterdays file...? (4 Replies)
Discussion started by: hemanthsaikumar
4 Replies

4. Shell Programming and Scripting

How to list files that are not first two files date & last file date for every month-year?

Hi All, I need to find all files other than first two files dates & last file date for month and month/year wise list. lets say there are following files in directory Mar 19 2012 c.txt Mar 19 2012 cc.txt Mar 21 2012 d.txt Mar 22 2012 f.txt Mar 24 2012 h.txt Mar 25 2012 w.txt Feb 12... (2 Replies)
Discussion started by: Makarand Dodmis
2 Replies

5. Shell Programming and Scripting

FTP files modified after a particular date between servers

Hi all, i need to write a shell script to transfer a file modified after a particular date from one server to another. I searched for the related posts in this forum and got hints and snippets for it. i tried the below code ftp serverA user uname pwd lcd to_dir cd from_dir files=$(find... (7 Replies)
Discussion started by: mick_000
7 Replies

6. Shell Programming and Scripting

Sorting Files by date and moving files in date order

I need to build a k shell script that will sort files in a directory where files appear like this "XXXX_2008021213.DAT. I need to sort by date in the filename and then move files by individual date to a working folder. concatenate the files in the working folder then start a process once... (2 Replies)
Discussion started by: rebel64
2 Replies

7. UNIX for Advanced & Expert Users

automated ftp script from unix -date range of files

Hi , I need some help to finish my ftp script and i need to find the last one weeks of fles updated in the sepecific directory and see those end with Z and ftp them to my backup server. Any help is appreciated. Thanks, Ravi :) (1 Reply)
Discussion started by: koduri0475
1 Replies

8. Programming

automated ftp script from unix -date range of files

Hi , I need some help to finish my ftp script and i need to find the last one weeks of fles updated in the sepecific directory and see those end with Z and ftp them to my backup server. Any help is appreciated. Thanks, Ravi :) (1 Reply)
Discussion started by: koduri0475
1 Replies

9. Shell Programming and Scripting

automated ftp script from unix -date range of files

Hi , I need some help to finish my ftp script and i need to find the last one weeks of fles updated in the sepecific directory and see those end with Z and ftp them to my backup server. Any help is appreciated. Thanks, Ravi :) (1 Reply)
Discussion started by: koduri0475
1 Replies

10. UNIX for Advanced & Expert Users

FTP "get" on files using date/time

hi! I want to "get/mget" files from a FTP server, selecting on age of existing files at remote host. example in natural lang: "get all files from FTP-server newer than 2 days". I'm presently trying to "output - grep - awk on date/time - mget". Doesn't work very good. Has any1... (6 Replies)
Discussion started by: jonascarlson
6 Replies
Login or Register to Ask a Question