2 # sample program of expect.rb
6 # This program reports the latest version of ruby interpreter
7 # by connecting to ftp server at ruby-lang.org.
13 PTY.spawn("ftp ftp.ruby-lang.org") do |r_f,w_f,pid|
16 $expect_verbose = false
18 r_f.expect(/^Name.*: /) do
23 username = ENV['USER']
24 elsif !ENV['LOGNAME'].nil?
25 username = ENV['LOGNAME']
30 r_f.expect('word:') do
31 w_f.print username+"@\n"
34 w_f.print "cd pub/ruby\n"
40 r_f.expect("> ") do |output|
41 for x in output[0].split("\n")
42 if x =~ /(ruby.*\.tar\.gz)/ then
53 print "The latest ruby interpreter is "