CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Copy file from ftp directory after successful upload

 



tbalz
New User

Aug 22, 2013, 11:41 AM

Post #1 of 3 (929 views)
Copy file from ftp directory after successful upload Can't Post

Hi Guys,

I would like to create a perl script that will copy a file from my ftp directory to a different directory once it has successfully uploaded to my server. I want to verify that it was successfully uploaded by looking at the /var/log/xferlog and then if I can parse out a successful message for the given filename it would move it away from the directory immediately. I would have this run in a cron job and need it to be completely automated. For example if 5 files were uploaded they would be instantly moved out the directory as soon as a "successful transfer" messaged was received for it in /var/log/xferlog. Any help will greatly be appreciated.


Laurent_R
Veteran / Moderator

Aug 22, 2013, 11:34 PM

Post #2 of 3 (920 views)
Re: [tbalz] Copy file from ftp directory after successful upload [In reply to] Can't Post

Hmm, if you want to move a file as soon as it has beed loaded successfully, then a cron might not be the best idea. Can't you trigger the copy within the program that runs the FTP transfer?


FishMonger
Veteran / Moderator

Aug 23, 2013, 6:38 AM

Post #3 of 3 (909 views)
Re: [tbalz] Copy file from ftp directory after successful upload [In reply to] Can't Post

Are the ftp uploads being done as a get or as a put i.e., is the upload initiated by a process on this server or from another server?

A common approach for this task is to have your script poll the upload dir for new files. If found, it will then poll every X seconds the file size of each file to see if it's growing. The upload is compete once the size stops growing, but that doesn't mean that it was successful. This is the point where you parse /var/log/xferlog to find that answer and then move or delete the file based on that status.

Do you have a test script that you're developing? If so, you should post it and provide detailed info on how it failing to accomplish the task and include any/all errors and warnings it produces.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives