I don''t remember exactly, but I think it didn''t work for me
either.
So, i changed my code to have the remote process wait for a signal and
send a SIGINT from the code like so:
shell = session.shell.sync
out = shell.killall "-INT $progname"
## do stuff
shell.exit
Unfortunately, with this mechanism, you''ll need to use a
''sync'' , else
your shell will exit before the remote process dies.
Of course, this might not work for you, if the process being opened is
not under your control.
regs
vivek
On 24/08/2007, Josh Durham <joshdurham at mac.com>
wrote:> I''m trying to do a session.process.open, but it seems to never
exit.
> If you look at the debug output, it did get an exit-status packet,
> but ''on_exit'' never gets called. If I change the command
to
> something more simple (like echo), it works.
>
> I can confirm via logging in manually the process indeed exited.
>
> Any ideas?
> - Josh
>
> The code:
>
> def installOSPackages(volumeName)
> session = Net::SSH.start(@serverAddress, @serverUser,
> @serverPassword, :paranoid => false, :verbose => :debug)
> print "Running: /usr/sbin/installer -pkg /System/Installation/
> Packages/OSInstall.mpkg -target \"/Volumes/#{volumeName}\" -lang
en -
> verboseR\n"
> session.process.open("/usr/sbin/installer -pkg /System/
> Installation/Packages/OSInstall.mpkg -target \"/Volumes/#{volumeName}
> \" -lang en -verboseR") do |installer|
> installer.on_success do |p|
> print "Starting installation.\n"
> p.puts "\n"
> end
> installer.on_stdout do |p, data|
> if data =~ /PHASE/
> print "--> #{data}"
> $stdout.flush
> end
> end
> installer.on_stderr do |p, data|
> $stderr.print "STDERR: #{data}"
> $stderr.flush
> end
> installer.on_failure do |p, status|
> print "Installer failed to start with status
#{status}\n"
> end
> installer.on_exit do |p, status|
> print "Installer exited with status #{status}\n"
> end
> end
> end
>
> Here is the debug log:
> [DEBUG] Thu Aug 23 17:26:55 -0700 2007 -- transport.session: waiting
> for packet from server...
> [DEBUG] Thu Aug 23 17:26:55 -0700 2007 --
> transport.incoming_packet_stream: reading 8 bytes from socket...
> [DEBUG] Thu Aug 23 17:26:55 -0700 2007 --
> transport.incoming_packet_stream: packet length(60) remaining(56)
> [DEBUG] Thu Aug 23 17:26:55 -0700 2007 --
> transport.incoming_packet_stream: received: "^\000\000\000\001\000\000
> \000''installer: The install was successful.\n"
> [DEBUG] Thu Aug 23 17:26:55 -0700 2007 -- transport.session: got
> packet of type 94
> [DEBUG] Thu Aug 23 17:26:55 -0700 2007 -- connection.driver:
> CHANNEL_DATA recieved (1:"installer: The install was
successful.\n")
> [DEBUG] Thu Aug 23 17:26:55 -0700 2007 -- transport.session: waiting
> for packet from server...
> [DEBUG] Thu Aug 23 17:26:55 -0700 2007 --
> transport.incoming_packet_stream: reading 8 bytes from socket...
> [DEBUG] Thu Aug 23 17:26:55 -0700 2007 --
> transport.incoming_packet_stream: packet length(36) remaining(32)
> [DEBUG] Thu Aug 23 17:26:55 -0700 2007 --
> transport.incoming_packet_stream: received: "b\000\000\000\001\000\000
> \000\vexit-status\000\000\000\000\000"
> [DEBUG] Thu Aug 23 17:26:55 -0700 2007 -- transport.session: got
> packet of type 98
> [DEBUG] Thu Aug 23 17:26:55 -0700 2007 -- connection.driver:
> CHANNEL_REQUEST recieved (1:exit-status)
> [DEBUG] Thu Aug 23 17:26:55 -0700 2007 -- transport.session: waiting
> for packet from server...
> [DEBUG] Thu Aug 23 17:26:55 -0700 2007 --
> transport.incoming_packet_stream: reading 8 bytes from socket...
>
> _______________________________________________
> Net-ssh-users mailing list
> Net-ssh-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/net-ssh-users
>