Heesob Park
4/16/2009 2:27:00 AM
2009=EB=85=84 4=EC=9B=94 16=EC=9D=BC (=EB=AA=A9) =EC=98=A4=EC=A0=84 9:59, J=
un Young Kim <jykim@altibase.com>=EB=8B=98=EC=9D=98 =EB=A7=90:
> 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.
>
Try this:
require 'open3'
include Open3
stdin, stdout, stderr =3D popen3("ftp -inv ftp.gnu.org")
while line=3Dstdout.gets
print line
end
I guess ftp is trying to interact with tty.
Using pty and expect is more suitable in this case
require 'pty'
require 'expect'
PTY.spawn('ftp ftp.gnu.org') do |r,w,cid|
r.expect /Name.*:\s+/ do |line|
print line
w.puts "anonymous"
end
while line=3Dr.gets
print line
end
end
Regards,
Park Heesob