Unix script to MOVE via FTP a directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unix script to MOVE via FTP a directory
# 1  
Old 10-13-2009
Unix script to MOVE via FTP a directory

Good afternoon!
I need to move a bunch of files from an FTP site to my server.
However mget *, dele * will not suffice as I cannot guarantee that new files are not uploaded between commands.
Roughly, this is what I would like to do:
Code:
 
(using a .netrc)
ftp somehost
bin
prompt
cd some_folder
ls > LIST_OF_FILES
bye
For each $FILE_1 in LIST_OF_FILES
ftp somehost
prompt
bin
cd some_folder
get $FILE_1
bye
crccheck $FILE_1 // (the filename is file_CRC#.txt) This can be done later..
ftp somehost prompt cd some_folder dele $FILE_1 bye end for each

My problems are:
1)when running ls > files.lst in my csh script, files.lst is always empty, for whatever reason the output is not making it in a file, if I run an ls without the >, I do see 20 files.
2) when I have my files.lst, I need help with an awk/sed etc loop
Thank you so much for your help / ideas.
Derek
# 2  
Old 10-13-2009
Quote:
ls > LIST_OF_FILES
The syntax for ftp commands is not the same as that for ftp commands. You will need to remove the ">" from the command line. See "man ftp" options "ls" or "dir" for the syntax of the ftp directory list command on your target Operating System. The format of the output from a ftp directory list is variable and you may need further shell code to extract the filenames.

Code:
ls LIST_OF_FILES


Last edited by methyl; 10-13-2009 at 07:28 PM.. Reason: Paraphrase.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script cannot create directory and move the file to that directory

I have a script, which is checking if file exists and move it to another directory if then mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly ... (9 Replies)
Discussion started by: digioleg54
9 Replies

2. Shell Programming and Scripting

Move file in to directory- script

Hi In directory /mnt/upload I have about 100 000 files (*.png) that have been created during the last six months. Now I need to move them to right folders. eg: file created on 2014-10-10 move to directory /mnt/upload/20141010 file created on 2014-11-11 move to directory /mnt/upload/20141111... (6 Replies)
Discussion started by: primo102
6 Replies

3. Shell Programming and Scripting

Script to move latest zip file to another directory

Hi folks, In my application there is a job running which create a .dat file along with it zip file also at unix box location /opt/app/cvf/temp1 so in temp1 directory I have one .dat file and its zip file also. Now since this job runs every day so if a job runs today there will be two files... (5 Replies)
Discussion started by: punpun66
5 Replies

4. Shell Programming and Scripting

Script to compare substrings of multiple filenames and move to different directory

Hi there, I am having trouble with a script I have written, which is designed to search through a directory for a header and payload file, retrieve a string from both filenames, compare this string and if it matches make a backup of the two files then move them to a different directory for... (1 Reply)
Discussion started by: alcurry
1 Replies

5. Programming

Script for creating a directory & move the .tif files in it.

Hi Team, I have thousands of TIF files which are converted from PDF. Below is a sample of it. LH9406_BLANCARAMOS_2012041812103210320001.tif LH9406_BLANCARAMOS_2012041812103210320002.tif LH9406_BLANCARAMOS_2012041812103210320003.tif LH9411_ANGENIAHUTCHINSON_2012041812102510250001.tif... (9 Replies)
Discussion started by: paragnehete
9 Replies

6. Shell Programming and Scripting

Is it possible to move a directory using ftp??

Hi all, Is it possible to move a directory using ftp service?? (2 Replies)
Discussion started by: eeegopikannan
2 Replies

7. Shell Programming and Scripting

Script to move files to a directory according to date

hi all, here is the description to my problem. input parameter: $date1 based on the date i need to select three files starting with audit.log* based on its modified date, a date before, a date after(if its exists). We need to compare the input date to modified date of the file. And then... (3 Replies)
Discussion started by: ashrocks
3 Replies

8. Shell Programming and Scripting

Move a file from windows directory to unix directory

Move a file from windows directory to unix directory, is this possible? if it is, can someone help me on this? Thanks! God bless! (1 Reply)
Discussion started by: kingpeejay
1 Replies

9. IP Networking

How to Transfer a whole Directory from unix to windows using FTP?

Hi I can transfer a single file and multiple file from unix to widows using get and mget command.But i dont know How to transfer a whole directory from unix to windows using command. pls help me Ramkumar (1 Reply)
Discussion started by: ramkumarm83
1 Replies

10. Shell Programming and Scripting

FTP script for sending a file from one unix directory to another unix server director

Hi, My local server is :/usr/abcd/ Remote server is :/Usr/host/test/ I want to send files from local unix directory(All files starting with O_999) to remote host unix directory. Can any body give me the Unix Shell script to do this. One more doubt: Shall we need to change the file... (1 Reply)
Discussion started by: raja_1234
1 Replies
Login or Register to Ask a Question