Perl script upload file to ftp server




















Parameter 5: SRC? Wavfiles, which is an array: Specify class a folder to place all voice files to be uploaded; Note: subfolders in this directory will also be uploaded. Parameter 6: SRC? In addition, I'm using some modules that are not in the standard distribution of Perl.

These modules can be obtained from CPAN at www. When you configured everything, simple execute the script by double-clicking it in the explorer or by typing " perl upload. The script writes output to stdout , as well as to a logfile called " upload. If you have any suggestions, found errors or want to comment on that article or script, please write a comment to at the end of this article and I will answer it. Please keep in mind that I'm doing Perl for only a few months right now.

So there are probably a lot of "no really beautiful" code-fragments in my script. So if you have any constructive comments regarding my coding style or the way I use Perl, please tell me! Sign in Email. Forgot your password? Search within: Articles Quick Answers Messages. Tagged as Win2K. Stats Uwe Keim Rate me:. Please Sign up or sign in to vote. Download source files - Theoretically, a file needs to be uploaded only if: the local modification date is newer than the remote modification date, or the remote file doesn't exist at all In practice, the problem is that the FTP-Server has another timebase e.

Upload Algorithm The solution presented in this article handles this by storing the modification dates of the files to upload in a local database and does the comparison with these timestamps. In a nutshell, the "algorithm" works, for each file to upload, like this: Does an entry for the file exist in the database? If no , upload it, create new recordset for this file, storing its path and modification date.

If yes , compare the actual modification date of the file with the stored modification date in the database. If actual modification date is newer than the stored one, upload the file, store its modification date in the database. If actual modification date is older than the stored one, do nothing. Starting from the second time, the script is executed, it works as described above.

The following extra modules need to be installed: libnet libnet Writing code in comment? Please use ide. Skip to content. Change Language. Related Articles. Table of Contents. Improve Article. Save Article. Paul Clapham. I know almost nothing about Perl, but what I know about FTP makes me wonder why the put function doesn't have an "or die" option. It's certainly possible for errors to occur during the upload, and it's important for you to know when that has happened.

Otherwise you get led down into the dark cave of wondering how you know whether the upload completed; you shouldn't have to do that in a proper FTP client implementation. What we generally do is check for a return or error code. If we are paranoid, we will also do an "ls" on the files local and remote and compare the sizes. If it matches, you can be pretty sure all is well.

If it doesn't, you can't tell if the problem was with the original put, or the secondary get.



0コメント

  • 1000 / 1000