Link to home
Start Free TrialLog in
Avatar of IT CAMPER
IT CAMPERFlag for United States of America

asked on

Recurring FTP uploads

I need to check a the modified date on a local XML file and if changed from last check then upload the file to an FTP site. I have tried a few applications to handle this but the applications are just not able to reliably run the routine 24/7 without crashing or running into various issues that require I babysit it more than I care to. I currently have an application checking the modified date every 3 minutes and uploading if changed. My initial requirement was for the application to run as a service since I host it on a server and did not want to require desktop load. However, I am okay now with just a running script that auto launches on login. Again, just looking for something reliable and I wonder if a script would make more sense and be reliable.
Avatar of Dr. Klahn
Dr. Klahn

Run it as a scheduled task every X minutes, then the script doesn't have to be started at startup time or sit around idle waiting for the next occurrence, and it can't be killed accidentally.  Should simplify things a bit.

Side note:  I assume you mean SFTP, not FTP.  FTP is completely insecure and passes account names and passwords in plaintext so that anybody attached to the local network can grab them.  If you're not using SFTP, then get the PuTTY psftp and switch over.  This will prevent some harsh words that would otherwise be coming your way at the next security audit.

https://www.puttygen.com/psftp
Avatar of IT CAMPER

ASKER

Thanks for the helpful info Dr. Klahn. I will certainly look into the SFTP side of it. I am actually looking for a script that can perform the duties described.
SO you have the script looping currently it sounds like, and must be saving the last modified date/time to a variable when you FTP it?  And then in the next loop check if it has changed?

If you change to something like saving the modified date when you upload to a text file then you can load and check that text file the next time the script runs, and compare to current file date to determine if it changed.

That way don't have to keep it running and looping, just run it every so many minutes from Task Scheduler, do the check, upload if needed (and update text file), and then quit.


»bp
I apologize guys, as I have failed in providing a critical detail. I don't have a script but are looking to see if a script would suffice and if so need help in creating said script. I am currently using an application to perform the task but it's failing at it's job. 
Well, the problem with VBS is that it doesn't have any native FTP support.  So you end up either trying to shell out to an FTP console app and feed a list of commands to do the upload (usually via a control file) and try to automate it.

Another approach with VBS is to automate IE to get it done, but I never went down that path.

I'm not sure if Powershell has native FTP support in it, I didn't think so, but it may have been added in a newer release.

It could potentially be done with a BAT script, but the date comparisons there get tricky, and you still end up using a console FTP tool of some sort.


»bp
Seems like a good application for a compiled Perl script.  There's a Perl module for everything.  Then run it out of the task scheduler and there's no need for it to run all the time.

Of course, it would be necessary to make an acceptable offering to the staff Perl guru.

ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can also just use rsync, which checks to see if a file has been modified.

If the file has been modified, the rsync occurs. Otherwise, all unmodified files are skipped.
Build it yourself. Use the free Visual Studio, start a VB.net console app, add WinSCP support, and with just about 20 lines of code, you'll have a lean but reliable app (the other is probably bloated, and has memory leaks). Add text file logging and you'll have a solid solution. Can be a service, but a hidden console running at a scheduled time will also work.