PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > sftp.put_file problems on Linux
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
sftp.put_file problems on Linux

Réponse
 
LinkBack Outils de la discussion
Vieux 10/03/2008, 18h26   #1
Milo Thurston
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut sftp.put_file problems on Linux

I have written a simple script to locate particular files on a server
and copy them elsewhere with sftp. There is one particular part of the
script that gives me some trouble:

<pre>
begin
sftp.put_file("#{ramdisk}/#{file}","#{dst_dir}")
rescue
puts "Message: #{sftp.status[:code]} (#{sftp.status[:message]})"
end
</pre>

The code dies at this point, with this error.

<pre>
Message: 0 (Success)
/var/lib/gems/1.8/gems/net-sftp-1.1.1/lib/net/sftp/operations/abstract.rb:78:in
`do_status': Net::SFTP::Operations::StatusException (4, "Failure")
(Net::SFTP::Operations::StatusException (4, "Failure"))
from
/var/lib/gems/1.8/gems/net-sftp-1.1.1/lib/net/sftp/session.rb:221:in
`do_status'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in
`to_proc'
from
/var/lib/gems/1.8/gems/net-sftp-1.1.1/lib/net/sftp/protocol/01/impl.rb:92:in
`call'
from
/var/lib/gems/1.8/gems/net-sftp-1.1.1/lib/net/sftp/protocol/01/impl.rb:92:in
`call_on_status'
from
/var/lib/gems/1.8/gems/net-sftp-1.1.1/lib/net/sftp/protocol/03/impl.rb:37:in
`do_status'
from
/var/lib/gems/1.8/gems/net-sftp-1.1.1/lib/net/sftp/protocol/01/impl.rb:189:in
`dispatch'
from
/var/lib/gems/1.8/gems/net-sftp-1.1.1/lib/net/sftp/protocol/driver.rb:189:in
`do_data'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in
`to_proc'
... 20 levels...
from
/var/lib/gems/1.8/gems/net-ssh-1.1.2/lib/net/ssh/session.rb:138:in
`initialize'
from /var/lib/gems/1.8/gems/net-ssh-1.1.2/lib/net/ssh.rb:47:in
`new'
from /var/lib/gems/1.8/gems/net-ssh-1.1.2/lib/net/ssh.rb:47:in
`start'
from ./sftp_script.rb:26
</pre>

Everything else is fine - the connection is set up properly and I can
use sftp.mkdir. Also, if I replace put_file with this, it works:

<pre>
scp_command = "scp #{ramdisk}/#{file}
#{user}@#{host}:/home/#{user}/#{dst_dir}"
unless system("#{scp_command}")
raise "Could not scp #{file}."
end
</pre>

This is less than ideal due to filling up the logs of the receiving
machine, though.
Does anyone know what might be causing the problem with put_file?
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 11/03/2008, 01h59   #2
Michael Steinfeld
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: sftp.put_file problems on Linux

Seems to me like your TCP connection is being killed by the server.
I'm guessing.

Try adding a keep-alive to your /etc/ssh/ssh_config

ServerAliveInterval 15

unlike sftp, scp will open a new connection for each file.



On Mon, Mar 10, 2008 at 1:26 PM, Milo Thurston <knirirr@gmail.com> wrote:
> I have written a simple script to locate particular files on a server
> and copy them elsewhere with sftp. There is one particular part of the
> script that gives me some trouble:
>
> <pre>
> begin
> sftp.put_file("#{ramdisk}/#{file}","#{dst_dir}")
> rescue
> puts "Message: #{sftp.status[:code]} (#{sftp.status[:message]})"
> end
> </pre>
>
> The code dies at this point, with this error.
>
> <pre>
> Message: 0 (Success)
> /var/lib/gems/1.8/gems/net-sftp-1.1.1/lib/net/sftp/operations/abstract.rb:78:in
> `do_status': Net::SFTP::Operations::StatusException (4, "Failure")
> (Net::SFTP::Operations::StatusException (4, "Failure"))
> from
> /var/lib/gems/1.8/gems/net-sftp-1.1.1/lib/net/sftp/session.rb:221:in
> `do_status'
> from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in
> `to_proc'
> from
> /var/lib/gems/1.8/gems/net-sftp-1.1.1/lib/net/sftp/protocol/01/impl.rb:92:in
> `call'
> from
> /var/lib/gems/1.8/gems/net-sftp-1.1.1/lib/net/sftp/protocol/01/impl.rb:92:in
> `call_on_status'
> from
> /var/lib/gems/1.8/gems/net-sftp-1.1.1/lib/net/sftp/protocol/03/impl.rb:37:in
> `do_status'
> from
> /var/lib/gems/1.8/gems/net-sftp-1.1.1/lib/net/sftp/protocol/01/impl.rb:189:in
> `dispatch'
> from
> /var/lib/gems/1.8/gems/net-sftp-1.1.1/lib/net/sftp/protocol/driver.rb:189:in
> `do_data'
> from /usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in
> `to_proc'
> ... 20 levels...
> from
> /var/lib/gems/1.8/gems/net-ssh-1.1.2/lib/net/ssh/session.rb:138:in
> `initialize'
> from /var/lib/gems/1.8/gems/net-ssh-1.1.2/lib/net/ssh.rb:47:in
> `new'
> from /var/lib/gems/1.8/gems/net-ssh-1.1.2/lib/net/ssh.rb:47:in
> `start'
> from ./sftp_script.rb:26
> </pre>
>
> Everything else is fine - the connection is set up properly and I can
> use sftp.mkdir. Also, if I replace put_file with this, it works:
>
> <pre>
> scp_command = "scp #{ramdisk}/#{file}
> #{user}@#{host}:/home/#{user}/#{dst_dir}"
> unless system("#{scp_command}")
> raise "Could not scp #{file}."
> end
> </pre>
>
> This is less than ideal due to filling up the logs of the receiving
> machine, though.
> Does anyone know what might be causing the problem with put_file?
> --
> Posted via http://www.ruby-forum.com/.
>
>


  Réponse avec citation
Vieux 11/03/2008, 10h37   #3
Milo Thurston
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: sftp.put_file problems on Linux

Michael Steinfeld wrote:
> Seems to me like your TCP connection is being killed by the server.
> I'm guessing.


Thanks for your reply.
I'm not sure that that's it, as my script includes other commands (e.g.
sftp.mkdir) that work fine even though all the put_file commands fail.
So, the connection must be remaining open. I can also use sftp on the
command line.
Could there be some sort of status message being returned from the ssh
connection that the Ruby code doesn't like?
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h54.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12755 seconds with 11 queries