On Feb 7, 2007, at 5:33 PM, Philippe de Rochambeau wrote:

Hello,

I would like to run a PERL script, which uses Net::FTP to retrieve a file and Mail::Sender to send it by email, from a PERL CGI.

Unfortunately, the second script never works ("script_that_retrieves_a_file_by_ftp_and_sends_it_by_email.pl" below), probably because the CGI ends before the child script has had a chance to do anything.

Does anyone have any suggestions as to how I could make the CGI wait for the second script to complete?
...
my $ret = ` "perl script_that_retrieves_a_file_by_ftp_and_sends_it_by_email.pl" `;

You are mistaken; the CGI cannot end before the child is finished. Backticks don't work that way, they cause Perl to wait until the called script is finished.

I suspect what's happening is that the script you're calling is doing something like forking its own child process to fetch and send the file in the background, and then returning immediately without waiting for that process to finish. When you run script_that_retrieves_etc from a shell prompt, does it return immediately?

sherm--

Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


Reply via email to