From: Tim McIntyre Date: 2007-06-28T06:24:03+09:00 Subject: copying files to remote machine Hey all, I've got a little script that is attempting to copy images to a remote server. The significant parts of the script were taken directly from recipe 14.11 in the ruby cookbook. relevant sections: # directly from cookbook recipe 14.11 def remote_copy(session, source_path, destination_path=nil) destination_path ||= source_path cmd = %{cat > "#{destination_path.gsub('"', '\"')}"} cat_process = session.process.open(cmd) cat_process.on_success do |p| p.write(open(source_path) { |f| f.read }) p.close puts "Copied #{source_path} to #{destination_path}." end end # slightly modified from same recipe Net::SSH.start ('remote.server.com', :username=>'user', :password=>'pass') do |session| Film.find(:all).each do |film| if film.small_local_cover_image_exists? remote_copy(session, film.small_local_cover_path, film.small_remote_cover_path) end end session.loop end When I run it works for about the first 4 or 5 films then dies with this message: /usr/lib/ruby/gems/1.8/gems/net-ssh-1.0.10/lib/net/ssh/transport/ session.rb:258:in `wait_for_message': disconnected: Received data for nonexistent channel 2. (2) (Net::SSH::Transport::Disconnect) from /usr/lib/ruby/gems/1.8/gems/net-ssh-1.0.10/lib/net/ssh/ transport/session.rb:242:in `wait_for_message' from /usr/lib/ruby/gems/1.8/gems/net-ssh-1.0.10/lib/net/ssh/ connection/driver.rb:148:in `process' from /usr/lib/ruby/gems/1.8/gems/net-ssh-1.0.10/lib/net/ssh/ connection/driver.rb:138:in `loop' from /usr/lib/ruby/gems/1.8/gems/net-ssh-1.0.10/lib/net/ssh/ session.rb:164:in `loop' from script/cron/move_images_to_static_server.rb:53 from /usr/lib/ruby/gems/1.8/gems/net-ssh-1.0.10/lib/net/ssh/ session.rb:127:in `initialize' from /usr/lib/ruby/gems/1.8/gems/net-ssh-1.0.10/lib/net/ ssh.rb:47:in `start' from script/cron/move_images_to_static_server.rb:37 ubuntu 6.06 "Dapper Drake" - ruby 1.8.4 - net-ssh 1.0.10 Thanks in advance for any help! Tim