Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!cme!libes From: libes@cme.nist.gov (Don Libes) Newsgroups: comp.lang.perl Subject: Re: Reading from STDOUT Keywords: reading from stdout Message-ID: <6020@muffin.cme.nist.gov> Date: 23 Aug 90 20:21:22 GMT References: <6182@jhunix.HCF.JHU.EDU> Reply-To: libes@cme.nist.gov (Don Libes) Organization: National Institute of Standards and Technology Lines: 24 In article <6182@jhunix.HCF.JHU.EDU> shan_x@jhuvms.bitnet writes: >I'm writing a perl script to send file with FTP. >To determine the responses from the FTPD, I need to read >from STDOUT. I can do this by redirecting STDOUT >to a file then read from the file. But this way I have >problem to synchronize the two processes. I have to put >"sleep(2)" everywhere. Any better solutions? Thanks. Since no one offered any Perl solutions, let me suggest using a different tool. (Is this a first for this newsgroup?) I don't know what the rest of your Perl script is doing, but for the part where you are interacting with ftp, consider using "expect" - a tool specifically designed for controlling interactive programs. Here is an expect fragment to send the file, foo.bar, and read the response from ftp, reporting ftp's error if appropriate. send put foo.bar\r expect timeout {exit -1} *success*ftp>* And yes, sigh, you can make this into one line if you want to. Don