synchronus ftp call

C

chris

I have the following bit of code that makes a call to the ftp binary.
The call seems to be happening asynchronusly. How can I make perl
wait for the print FTP statement to finish?

Is there a better way of doing this (e.g. system() call, etc.,)? My
perl version is 5.005_02 built for PA-RISC1.1. I am not able to use
any perl libs such as Net::Ftp.

#################################

open FTP, "|$FTP -n" or die $!;

print FTP <<EndFTP
open $FTP_SITE
user $FTP_USER
pass $FTP_PASS
get README
quit
EndFTP

#################################

Thanks in advance,

Chris
 
B

Brian McCauley

chris said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top