Carl Youngblood
10/9/2004 6:58:00 AM
Okay, I set up ruby again and net-ssh appears to be working properly.
At least, rpa didn't give me any errors during install and I have been
able to get some of it to work. However, when I run the following
little test app, it successfully copies the two files to the server,
but it hangs indefinitely after it's finished. I thought that when I
started a session in block mode it was supposed to exit automatically
after everything was finished. Is there something I'm missing?
Thanks,
Carl
--------------------------
#!/usr/bin/env ruby
require 'net/ssh'
require 'net/ssh/sftp'
Net::SSH.start('host', 'user', 'pass') do |session|
Net::SSH::SFTP.session(session) do |sftp|
sftp.put('file1', 'contents') do |status|
if status[:code] != Net::SSH::SFTP::Session::SSH_FX_OK
raise "error (#{status[:code]}, #{status[:message]})"
else
puts "success"
end
end
sftp.put('file2', 'contents') do |status|
if status[:code] != Net::SSH::SFTP::Session::SSH_FX_OK
raise "error (#{status[:code]}, #{status[:message]})"
else
puts "success"
end
end
end
session.main_loop
end