From: Jun Young Kim Date: 2009-04-16T09:59:28+09:00 Subject: Re: using popen yes, ftp client is waiting some letters for log-in. but, before that, client program print out "hello message" like -------------------------------------------------- Connected to ftp.gnu.org. 220 GNU FTP server ready. Name (ftp.gnu.org:junyoung): -------------------------------------------------- under a hanging situation, I cannot also see this message. anyway. (a) I tried to get 1byte by sysread. it's not different. (b) Is interactive tty different from stdin, stdout? I believe although ftp is using tty, it should print out something in stdout. 2009. 04. 15, ¿ÀÈÄ 10:01, Brian Candler ÀÛ¼º: > Jun Young Kim wrote: >> ---------------------------------------------------------- >> require 'open3' >> include Open3 >> >> stdin, stdout, stderr = popen3("ftp ftp.gnu.org") >> >> puts stdout.sysread(1024) >> ---------------------------------------------------------- >> >> looks like a hang. >> >> Could you tell me why this thing is happened? > > Probably because (a) the ftp client is waiting for data from the > terminal before it has sent 1024 bytes of reply, and/or (b) the ftp > client expects to be run on an interactive tty. > > If (b) applies, look at using require 'pty' > > But for FTP, you are almost certainly better off using Net::FTP from > the > Ruby standard library, rather than spawning an external ftp client. > -- > Posted via http://www.ruby-forum.com/. > >