From: "Ara.T.Howard" Date: 2004-04-15T01:09:20+09:00 Subject: Re: ruby pty/expect help On Wed, 14 Apr 2004, ts wrote: > >>>>> "A" == Ara T Howard writes: > > A> i've been up for a really long time, so perhaps i'm missing something silly, > A> but this script 'seems' to work (all three dots are printed), but no id_rsa > A> file is made? > > You must read its output thanks guy - what exactly do you mean? there's only one thing to read, and reading it seems the throw errors: ~/eg/ruby > cat ssh-keygen.rb require 'pty' require 'expect' $VERBOSE=nil path = ARGV.shift || 'id_rsa' File.unlink path rescue nil PTY.spawn 'ssh-keygen -t rsa' do |r,w,cid| r.expect %r/^Enter.*:\s+/ do |line| print line w.puts path end r.expect %r/^Enter.*:\s+/ do |line| print line w.puts '' end r.expect %r/^Enter.*:\s+/ do |line| print line w.puts '' end r.read # ?? this raises Errno::EIO w.flush w.close puts end ~/eg/ruby > ruby ssh-keygen.rb Generating public/private rsa key pair. Enter file in which to save the key (/home/ahoward/.ssh/id_rsa): id_rsa Enter passphrase (empty for no passphrase): Enter same passphrase again: ssh-keygen.rb:22:in `read': Input/output error - /dev/pts/19 (Errno::EIO) from ssh-keygen.rb:22 from ssh-keygen.rb:8:in `spawn' from ssh-keygen.rb:8 without the read it generates the expected output, but no id_rsa file is produced and no error is given... doesn't the call to IO.expect do the reading anyhow? also, the example in ext/pty/example_expect.rb doesn't seem to do any reading either? > A> do i have to signal the child to die or something? any other > A> useful debugging tips? > > $expect_verbose = true > > > Guy Decoux this is very helpful - and it was right in the example! ;-) -a -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328 | URL :: http://www.ngdc.noaa.gov/stp/ | TRY :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done ===============================================================================