Computing.Net > Forums > Unix > Looping through files to ftp

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Looping through files to ftp

Reply to Message Icon

Name: cleininger
Date: February 5, 2007 at 12:52:03 Pacific
OS: Unix
CPU/Ram: P4 / 1 GIG
Product: home burger
Comment:

I wrote an ftp shell script that ftp's everything in a particular dir using mput *

Instead of blindly ftp'ing every file in the directory, I want to:

1. ftp a file
2. mv that file to a archive folder
3. delete the file from the source folder
4. repeat 1-3 with the next file(s)
5. repeat until dir is empty

Can someone be able to post some code examples on how to do this?

Craig-



Sponsored Link
Ads by Google

Response Number 1
Name: thepubba1
Date: February 6, 2007 at 08:23:29 Pacific
Reply:

for file in *
do
{your ftp code here substituting "put $file' in place of "mput *'}
mv $file /mydir
if [[ $? -eq 0 ]]
then
rm $file
else
print "Error moving $file"
exit 1
fi
done

This should do the trick.


0
Reply to Message Icon

Related Posts

See More


basic unix scripting help Moveing content of files ...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Looping through files to ftp

adding date to ftp script...urgent www.computing.net/answers/unix/adding-date-to-ftp-scripturgent/5355.html

loop through directory grep file at www.computing.net/answers/unix/loop-through-directory-grep-file-at/6903.html

ftp ing Unix files to c:\ www.computing.net/answers/unix/ftp-ing-unix-files-to-c/3006.html