chris wrote:
> Subject: synchronus ftp call
> I am not able to use any perl libs such as Net::Ftp.
You are not partitioning your question correctly. You've concuded that
you are not able to use Net::FTP but need to use a subprocess. As such
the Perl part of your question is only about handling subprocesses an
not about FTP.
> I have the following bit of code that makes a call to the ftp binary.
> The call seems to be happening asynchronusly.
> open FTP, "|$FTP -n" or die $!;
>
> print FTP <<EndFTP
> open $FTP_SITE
> user $FTP_USER
> pass $FTP_PASS
> get README
> quit
> EndFTP
When you issue a close(FTP) perl will wait for the subrocess to complete.
> How can I make perl wait for the print FTP statement to finish?
It is not the print statement you want to wait for, it is the subrocess.
> Is there a better way of doing this (e.g. system() call, etc.,)?
You can put the ftp session input into a temporary file then use
system(). This, of course, has little to do with Perl - it would apply
equally in most languages.
|