How can we automate an FTP action from a folder on our server?
June 5, 2009 9:19 AM   Subscribe

Question #1767346834 in our exhausting ERP integration process: Is there a way to automate an FTP process so that "Everytime file x lands in folder y, we send file x to ftp://whatever/import"? More inside.

So, our unbearably expensive ERP lacks some common features. It has some pretty heinous import/export functionality which has made sending and receiving information a major struggle. But after an endless string of late-nights/all-nighters, we're getting somewhere!

New problem: The system is more than happy to export stuff. But it won't FTP it anywhere. Because we've got about 100+ files exporting a day, it's almost impossible to be doing this manually. The most it will do is reliably export it to the same folder on it's own server every time.

So we need to set up a process where anytime a file lands in that folder, it sends it along to our warehouse, which has it's own FTP.

posted by GilloD to Technology (9 answers total)
What kind of OS is it? With Linux there's a lot of ways with shell-scripts, php, perl, etc., depending on what you're familiar with.
If it's Windows or DOS, something like this works:

goto RunLoop

if exist *.* for %%D in (*.*) do set FILENAME=%%D
if exist %FILENAME% goto FoundFile
Sleep 1
goto RunLoop

{put unattended FTP command here}
goto RunLoop
posted by AzraelBrown at 9:26 AM on June 5, 2009

It's pretty simple to set folder actions in OSX also.
posted by unixrat at 9:29 AM on June 5, 2009

You are almost certainly looking for Bulletproof FTP which can monitor folders, send notifications, move files automagically when it detects new ones, and all manner of other cool things.
posted by disillusioned at 9:30 AM on June 5, 2009 [1 favorite]

Response by poster: Windows. LE SIGH. I'll take a look at Bulletproof, thanks!
posted by GilloD at 9:33 AM on June 5, 2009

How about a shell script run by cron (if Unix) or a Windows scheduled job (if Windows), that polls the source folder every couple of minutes/half an hour/day, then (if there are files present) establishes an ftp connection and sends the files.

(In my experience the reason it won't do the FTP out of the box is because the company also want to sell you their unbearably expensive middleware/integration product as well.)
posted by Electric Dragon at 9:35 AM on June 5, 2009

Response by poster: Electric- You are dead on. Their business model is "We have no manual, 3/4 of the software is still in French, so if you have a question, ask us. Our going rate is 100$ an hour". It has been a neverending nightmare.
posted by GilloD at 9:39 AM on June 5, 2009

Can you set up rsync instead? It's more reliable and more efficient, especially when transferring files in bulk that have some chance of being related (rsync is so good it's kind of spooky).

You will still have the cron issue. Cygwin has a cron server that suffice and will run as a Windows Service.

Sounds like you are in old-school IT hell. I will send happy thoughts your way.
posted by chairface at 10:03 AM on June 5, 2009

Take a look at PowerShell. The windows guys at work seem to think it's the greatest thing since sliced bread (I think it's windows finally discovering /bin/sh thirty years later but whatever).

This and the links therein make it sound like you can even do the FTP-ing itself through Powershell and it ought to be trivial to run that via Windows Scheduler.

Post code if it works!

(Also, Stack Overflow and Server Fault are other good resources to ask things like this. Not that Mefi doesn't rock at it, but sometimes sheer quantity of answers is useful.)
posted by Skorgu at 5:49 PM on June 5, 2009

How does it access the folder on the server? Can you create a mapped drive to the target machine and just have it save it there?
posted by gjc at 6:19 PM on June 5, 2009

« Older S-A-T-U-R-D-A-Y NIGHT!   |   Which host offers the most interpreters? Newer »
This thread is closed to new comments.