views:

64

answers:

2

I am looking for a good way to manage the access to an external FTP server from various programs on a single server. Currently I am working with a lock file, so that only one process can use the ftp server at a time. What would be a good way to allow 2-3 parallel processes to access the ftp server simultaneously. Unfortunately the provider does not allow more sessions and locks my account for a day if too many processes access their server. Used platforms are Solaris and Linux - all ftp access is encapsulated in a single library thus there is only 1 function which I need to change. Would be nice if there is something on CPAN.

+4  A: 

I'd look into perlipc(1) for SystemV semaphores or modules like POSIX::RT::Semaphore for posix semaphores. I'd create a semaphore with a resource count of 2-3, and then in the different process try to get the semaphore.

piotr
Great suggestion - I have installed it on both platforms and have tested it on Solaris with success...
weismat
+1  A: 

Instead of making a bunch of programs wait in line, could you create one local program that handled all the remote communication while the local programs talked to it? You effectively create a proxy and push that complexity away from your programs so you don't have to deal with it in every program.

I don't know the other constraints on your problem, but this has worked for me on similar issues.

brian d foy
Unfortunately this would not work - the created files are periodically updated and I want to avoid sending incomplete files, thus the caller needs to know when the ftp has finished. (it requires two-sided coordination).
weismat