ftp: get list of file to get. Retrieve and move them


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ftp: get list of file to get. Retrieve and move them
# 8  
Old 12-16-2007
That will do nicely.
# 9  
Old 12-16-2007
May wanna check this script too, it uses lftp instead.
# 10  
Old 12-17-2007
I need a little bit of help from you. I have a similar task, well maybe not. Anyway. I have a list of files that I need to get from an ftp server. I cannot figure out how to parse that list and have it read into my ftp script. Your script is the closest that I have come to finding the answer, but I am not clear on how to actually make this work. I have tried a loop, but seeing that I am already inside of the ftp code block when I try this:

while read line; do "$file"; done < <(cat filename.txt)

My script works fine if I want to download 1 file at a time, but I have about 35 specific files that need to be downloaded.

I am truly lost, please help me if you can. I hope this is clear, I have been out of the industry for 2 yeas and i am just getting back into the saddle, Im a bit rusty.

Thanks in advance.

Quote:
Originally Posted by bbabr
That did the job!

I managed to get the file list, create the todo.lst and run it. One thing I found, though, is that you have to delete the todo.lst after running the script. If not, the next time you run it, it will append to the file.

Below is the script I have. Any comments and suggestions on making it better would be greatly appreciated.

Code:
#!/bin/sh
clear
# change local directory
cd [local-directory]

#collect file names
ftp -ni ftp.abccompany.com <<EOF
user [user] [password]
cd /OUT
mls W945*.* list.txt 
quit
EOF

# create ftp action list
echo >>todo.lst user [user] [password]
while read N
do
    echo >>todo.lst cd /OUT
    echo >>todo.lst get $N
    echo >>todo.lst rename $N ARCHIVE/$N
done <list.txt

echo >>todo.lst quit

# ftp transfer process
ftp -nv ftp.abccompany.com <todo.lst

# cleanup
rm todo.lst

Thanks again!
# 11  
Old 06-24-2009
Perfect job
thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Move file from one directory and update the list file once moved.

Dears, I have a listfile contains list of files path. i need to read the line of the listfile mv the file to other directory and update the listfile by deleting the lines of the listfile. #!/bin/bash target=/fstest/INVESTIG/Sadiq/TEST_ARCH while read -r line || ]; do mv $line... (19 Replies)
Discussion started by: sadique.manzar
19 Replies

2. Shell Programming and Scripting

List the file names available on FTP server before selecting the required file

Below is my script code.which shows the environment name and then fetch the file from the ftp server but I am facing one issue.The script should be run in both way.We can pass the arguments with script and select the environment name then file name.Here the issue is I am not able to list the files... (1 Reply)
Discussion started by: anuragpgtgerman
1 Replies

3. UNIX for Dummies Questions & Answers

Move file using a file list

Hello, I have a text file name "filelist" which stores the file names of the files I want to move (the file names does not include the directory). Each of the name is in 1 line, and all the file are in directory: /cluster/home/input (along with other unrelated files). I want to move all the... (7 Replies)
Discussion started by: warmboy610
7 Replies

4. Shell Programming and Scripting

How to move a file in ftp command to other location?

hi, when i do ftp from unix to laptop which is running a windows os, it lands in a root folder. can i move a file from this root ftp folder to any other location in my laptop say , c:\files\ folder? i used rename command inside ftp , but it says incorrect parameter. (5 Replies)
Discussion started by: Little
5 Replies

5. Shell Programming and Scripting

Shell script to get the latest file from the file list and move

Hi, Anybody help me to write a Shell Script Get the latest file from the file list based on created and then move to the target directory. Tried with the following script: got error. A=$(ls -1dt $(find "cveit/local_ftp/reflash-parts" -type f -daystart -mtime -$dateoffset) | head... (2 Replies)
Discussion started by: saravan_an
2 Replies

6. Shell Programming and Scripting

Retrieve lines that match any occurence in a list of patterns

I have two files. The first containing a header and six columns of data. Example file 1: Number SNP ID dbSNP RS ID Chromosome Result_Call Physical Position 787066 SNP_A-8575395 RS6650104 1 NOCALL 564477 786872 SNP_A-8575125 RS10458597 1 AA ... (13 Replies)
Discussion started by: Selftaught
13 Replies

7. Shell Programming and Scripting

How to move the older than 30 file to another ftp server

Hi All I need to move the older than 30 days file to another ftp server. I have source structure like this Files folder Folder1 Folder2 Folder3 I need to create same Target structure and I need to move the older than 30 day file to another ftp server, can you please suggest me how I develop... (1 Reply)
Discussion started by: murari83.ds
1 Replies

8. Shell Programming and Scripting

awk to retrieve the particular value from a same list of xml tags

Hi All, I have the following code in one of my xml file: <com:parameter> <com:name>secretKey</com:name> <com:value>31XA874821172E89B00B1C</com:value> </com:parameter> <com:parameter> <com:name>tryDisinfect</com:name> <com:value>false</com:value> </com:parameter> <com:parameter>... (4 Replies)
Discussion started by: mjavalkar
4 Replies

9. Shell Programming and Scripting

After FTP unable to move file to other location

Hi Experts, I am using below script and facing some problems.. cd /home/user/test rm ftp://ftp.log Example: A_Bachfile_09292011.txt A=`ls -1 "A*.txt"` compress $A C=`ls -1 "A*` hostname="test.gmail.com" user="raju" Password="******" ftp -n $hostname <<EOF >>ftp.lpg... (4 Replies)
Discussion started by: rajubollas
4 Replies

10. Shell Programming and Scripting

how to move a file from one server to another server using FTP in shell script?

I have a file --> file1.txt i need to copy this file to another server using FTP....the 2 servers are server1 and server2..may i know how to write a script that can do this? thanks in advance! Im a newbie to this... (4 Replies)
Discussion started by: forevercalz
4 Replies
Login or Register to Ask a Question