Creating a list of files retrieved from MGET


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Creating a list of files retrieved from MGET
# 1  
Old 09-12-2012
Creating a list of files retrieved from MGET

Is there a way to create a txt file with the names of the files I retreive using mget *.file. I want to use this file as input to a delete command.

Using HP-UX
# 2  
Old 09-12-2012
Yes, use the ls or dir commands from a ftp session first and save the output for further processing.

Apart from being able to deduce that this is a question about the unix ftp command from the mention of mget there is no mention of any environmental details like Operating Systems, Shells or other useful details.

Let's see your attempt first.

Last edited by methyl; 09-12-2012 at 07:51 PM.. Reason: typos
# 3  
Old 09-12-2012
Assumption here is you are using a .netrc file for login and password and that filenames don't have space.

Now just do ls *.file and then use this a input to build your get and del commands:

Code:
file_list=$(ftp your_host <<EOF
cd /your/dir
ls *.file
quit
EOF)
 
cmd=$(echo $file_list | awk 'length{printf "get %s\ndel %s\n", $1, $1}' RS=" ")
 
ftp your_host <<EOF
cd /your/dir
$cmd
quit
EOF

Edit: @Methyl - Great minds think alike
# 4  
Old 09-13-2012
Will try this. Thanks for the info.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

FTP mget will only grab files not folders

Hey All, first post :rolleyes: So I am writting a script to pull down files from an ftp that will be called from a bat file on windows. This seems pretty straight forward, and grabs all of the "files" in the cd location, but I am running into some permission issue that will not allow me to... (1 Reply)
Discussion started by: mpatton
1 Replies

2. UNIX for Dummies Questions & Answers

FTP SERVER logging of files retrieved

Is there any addon or finctionality in ftp (SFTP) Server that definitively indicates if a file was retireved and successfully? I am looking for this type of command with logging so -files retrieved -files deleted by remote users can be logged Must be compatible with AIX and UBUNTU. ... (0 Replies)
Discussion started by: cdc01
0 Replies

3. Shell Programming and Scripting

sort retrieved data files in different dirs

Hi, I have a script to retrieve data files from server and store them in a directory on local disk. The script runs everyday as cron job. But now those files are too many so my boss wants me to put the files into different directories base on dates. Those files look like this: ... (4 Replies)
Discussion started by: leafei
4 Replies

4. UNIX for Dummies Questions & Answers

Mget issue: not transferring more than 2 files

I am trying to transfer about 3000 files from a window platfrom to my linux server. the scrip is pretty simple ftp to the source server (windows) cd to source directory lcd to destination directory mget *.jpg what I get in the log file is: mget 07421001.jpg? 200 PORT command successful.... (4 Replies)
Discussion started by: Doveman
4 Replies

5. Shell Programming and Scripting

Copying a files from a filter list and creating their associated parent directories

Hello all, I'm trying to copy all files within a specified directory to another location based on a find filter of mtime -1 (Solaris OS). The issue that I'm having is that in the destination directory, I want to retain the source directory structure while copying over only the files that have... (4 Replies)
Discussion started by: hunter55
4 Replies

6. UNIX for Dummies Questions & Answers

Creating a list of files in directory?

Hi All, I would like to do a loop on all the files with extension .out in my directory this files should be sorted alphabetically. Then I need to assign to each of them a progressive ID of three digits (maybe in HEX format?). First I tried to list manually the files as ARRAY=( A-001.out ... (5 Replies)
Discussion started by: f_o_555
5 Replies

7. Shell Programming and Scripting

Cannot copy files using mget

I performed the following operations: - ftp - open xxx.xxx.xxx.xxx - username, password - dir 200 PORT command succesful 150 Opening ASCII mode data connection for /bin/ls I see some files and 1 directory - I digit: mget * for each file I see: mget .\nomefile? Y 200 PORT command... (9 Replies)
Discussion started by: andreac81
9 Replies

8. UNIX for Dummies Questions & Answers

mget new files only

Hi all, I am currently in the process of setting up an FTP server with limited knowledge :p. I have run into an issue that i need some help with. Basically i want to be able to download files off another remote server twice a day every day but i want to make sure it only downloads new... (1 Reply)
Discussion started by: mokachoka
1 Replies

9. UNIX for Dummies Questions & Answers

Creating a List of Files With Find

Hi, I need to go through all the files on my system and build a list/output file with the paths of all files where the first two characters within the file match an expression. I know I can use something like find . | xargs cut -b1-2 or find . -exec cut -b1-2 {} \; to get the characters... (3 Replies)
Discussion started by: 008_
3 Replies

10. Shell Programming and Scripting

mget * (obtein files from current directory but not the files form sub-directories)

Hello, Using the instruction mget (within ftp) and with "Interactive mode off", I want to get all files from directory (DirAA), but not the files in sub-directories. The files names don't follow any defined rule, so they can be just letters without (.) period Directory structure example: ... (0 Replies)
Discussion started by: Peter321
0 Replies
Login or Register to Ask a Question