From: "Ara.T.Howard" Date: 2004-04-15T12:09:12+09:00 Subject: Re: ruby pty/expect help On Thu, 15 Apr 2004 nobu.nokada@softhome.net wrote: > Hi, > > At Thu, 15 Apr 2004 01:09:20 +0900, > Ara.T.Howard wrote in [ruby-talk:97152]: > > ~/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? > > Because the watchdog thread created by PTY.spawn signals the main thread > when child exits, and read(2) is interrupted. In such case, however, I feel > that IO#read should return already read data, if exists. perhaps a handle on an object which can be 'closed' could be returned instead of an array of Files, etc: passphrase = gen_random_passphrase pty = PTY.spawn 'ssh-keygen' pty.stdin.puts 'id_rsa.pub' pty.stdin.puts passphrase pty.stdin.puts passphrase pts.close # do the right thing pty = PTY.spawn 'ssh-agent' pty.stdin.write passphrase ... > BTW, you don't need PTY at all to generate ssh key > automatically. see above - i want to pass it to ssh-agent. thanks though, didn't know that... -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 ===============================================================================