Jeffery Smith
2008-Oct-20 13:46 UTC
[Net-ssh-users] Ruby/Net-SSH - new error when downloading file
Greeting all,
Sorry to send this twice...I just realized I did not put a subject line
(which I find personally annoying). So I am resending with a subject
line. Sorry for the redundancy.
I am stumped and I am hoping someone can help me out. I have been
running into an error when trying to download a file via SFTP. The
script I am using had been working until last week. I am still
searching for anything that might have been updated on my system, but
have had no luck.
This is the error:
$ ./get-sftpfile.rb -srcfilepath /remotedir/file.txt -dstfilepath
/localdir/file.txt
Connecting to remote SFTP server username at ftp.test.com
SSH Session open, starting SFTP.
SFTP Session open, connecting.
Logged into SFTP server, downloading file: /remotedir/file.txt
/usr/lib/ruby/1.8/net/sftp/operations/abstract.rb:78:in `do_status'':
Net::SFTP::Operations::StatusException (8, "The request is not
supported. ") (Net::SFTP::Operations::StatusException (8, "The request
is not supported. "))
from /usr/lib/ruby/1.8/net/sftp/session.rb:221:in `do_status''
from
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `to_proc''
from /usr/lib/ruby/1.8/net/sftp/protocol/01/impl.rb:92:in
`call''
from /usr/lib/ruby/1.8/net/sftp/protocol/01/impl.rb:92:in
`call_on_status''
from /usr/lib/ruby/1.8/net/sftp/protocol/03/impl.rb:37:in
`do_status''
from /usr/lib/ruby/1.8/net/sftp/protocol/01/impl.rb:189:in
`dispatch''
from /usr/lib/ruby/1.8/net/sftp/protocol/driver.rb:189:in
`do_data''
from
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `to_proc''
... 31 levels...
from /usr/lib/ruby/1.8/net/ssh.rb:47:in `new''
from /usr/lib/ruby/1.8/net/ssh.rb:47:in `start''
from ./get-sftpfile.rb:107:in `download_from_sftpserver''
from ./get-sftpfile.rb:131
The script is extremely simple. I''ve included it below.
get-sftpfile.rb:
#!/usr/bin/ruby
#=============================================================================
# Required modules
#-----------------------------------------------------------------------
--------
require ''rubygems''
require ''active_support''
require ''zip/zip''
require ''net/ssh''
require ''net/sftp''
require ''fileutils''
require ''ftools''
require ''find''
require ''optiflag''
module FTPtransferOptions extend OptiFlagSet
flag "srcfilepath" do
description "Full path to source file on SFTP server"
end
flag "dstfilepath" do
description "Full path to local destination for downloaded
file"
end
and_process!
end
#=============================================================================
# Program variables
#-----------------------------------------------------------------------
--------
src_filepath = ARGV.flags.srcfilepath
src_file = File.basename(src_filepath)
dst_filepath = ARGV.flags.dstfilepath
dst_dir = File.basename(dst_filepath)
repo_dir = "/home/file_repository/"
repo_filepath = repo_dir + src_file
sftp_server = "ftp.test.com" #Not a real server or credentials
sftp_user = "user"
sftp_pass = "password"
#=============================================================================
# Functions
#-----------------------------------------------------------------------
--------
def download_from_sftpserver(remote_filepath, sftpaddr, sftpuser,
sftppass, local_filepath)
puts "Connecting to remote SFTP server " + sftpuser +
"@" +
sftpaddr.to_s
Net::SSH.start(sftpaddr, sftpuser, sftppass) do |ssh_session|
puts "SSH Session open, starting SFTP."
Net::SFTP::Session.new(ssh_session) do |sftp_session|
puts "SFTP Session open, connecting."
sftp_session.connect
puts "Logged into SFTP server, downloading file:
"
+ remote_filepath
sftp_session.get_file(remote_filepath,
local_filepath)
puts "Download finished, logging out."
end
end
end
#=============================================================================
# Main Program
#-----------------------------------------------------------------------
--------
download_from_sftpserver(src_filepath, sftp_server, sftp_user,
sftp_pass, repo_filepath)
if File.exist?(repo_filepath)
FileUtils.cp(repo_filepath, dst_filepath)
if File.exist?(dst_filepath)
puts "File delivery successful: " + dst_filepath
puts "Encrypting repository copy..."
repo_encrypt_file(repo_filepath)
puts "Removing unencrypted file."
File.delete(repo_filepath)
puts "Job success - Exit 0"
exit 0
else
puts "Cannot deliver file to destination: " +
dst_filepath
puts "Job failure - Exit 2"
exit 2
end
else
puts "Cannot find repository file: " + repo_filepath
puts "Job failure - Exit 1"
exit 1
end
#=============================================================================
# The END
#=============================================================================
Does anyone have any ideas?
Thanks in advance for any help anyone is able to offer!
Jeff
Jeffery Smith - Server Administrator - jeffsmith at dcu.org
Digital Federal Credit Union - www.dcu.org
508-263-6851 desk | 774-245-7940 cell | 866-383-9879 fax
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/net-ssh-users/attachments/20081020/075a9467/attachment-0001.html>
Kyle Rabe
2008-Oct-21 05:09 UTC
[Net-ssh-users] Ruby/Net-SSH - new error when downloading file
Jeff, I never had much luck using Net::SSH and then Net::SFTP for file uploads/downloads. If it would work for you, you could try a simpler approach: ----------------------------------- require ''net/sftp'' Net::SFTP.start(host, user, ...) do |sftp| sftp.download source_file, destination_file end ----------------------------------- I realize that this doesn''t really help you understand your error, but it might help you get the job done anyway. -Kyle On Mon, Oct 20, 2008 at 4:46 PM, Jeffery Smith <jeffsmith at dcu.org> wrote:> Greeting all, > > > > Sorry to send this twice?I just realized I did not put a subject line > (which I find personally annoying). So I am resending with a subject line. > Sorry for the redundancy. > > > > I am stumped and I am hoping someone can help me out. I have been running > into an error when trying to download a file via SFTP. The script I am > using had been working until last week. I am still searching for anything > that might have been updated on my system, but have had no luck. > > > > This is the error: > > > > *$ ./get-sftpfile.rb -srcfilepath /remotedir/file.txt -dstfilepath > /localdir/file.txt* > > Connecting to remote SFTP server username at ftp.test.com > > SSH Session open, starting SFTP. > > SFTP Session open, connecting. > > Logged into SFTP server, downloading file: /remotedir/file.txt > > */usr/lib/ruby/1.8/net/sftp/operations/abstract.rb:78:in `do_status'': > Net::SFTP::Operations::StatusException (8, "The request is not supported. ") > (Net::SFTP::Operations::StatusException (8, "The request is not supported. > "))* > > * from /usr/lib/ruby/1.8/net/sftp/session.rb:221:in `do_status''* > > * from > /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `to_proc''* > > * from /usr/lib/ruby/1.8/net/sftp/protocol/01/impl.rb:92:in `call''* > > * from /usr/lib/ruby/1.8/net/sftp/protocol/01/impl.rb:92:in > `call_on_status''* > > * from /usr/lib/ruby/1.8/net/sftp/protocol/03/impl.rb:37:in > `do_status''* > > * from /usr/lib/ruby/1.8/net/sftp/protocol/01/impl.rb:189:in > `dispatch''* > > * from /usr/lib/ruby/1.8/net/sftp/protocol/driver.rb:189:in > `do_data''* > > * from > /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `to_proc''* > > * ... 31 levels...* > > * from /usr/lib/ruby/1.8/net/ssh.rb:47:in `new''* > > * from /usr/lib/ruby/1.8/net/ssh.rb:47:in `start''* > > * from ./get-sftpfile.rb:107:in `download_from_sftpserver''* > > * from ./get-sftpfile.rb:131* > > > > > > The script is extremely simple. I''ve included it below. > > > > *get-sftpfile.rb:* > > #!/usr/bin/ruby > > > #==============================================================================> > # Required modules > > > #------------------------------------------------------------------------------- > > require ''rubygems'' > > require ''active_support'' > > require ''zip/zip'' > > require ''net/ssh'' > > require ''net/sftp'' > > require ''fileutils'' > > require ''ftools'' > > require ''find'' > > require ''optiflag'' > > > > module FTPtransferOptions extend OptiFlagSet > > flag "srcfilepath" do > > description "Full path to source file on SFTP server" > > end > > > > flag "dstfilepath" do > > description "Full path to local destination for downloaded > file" > > end > > > > and_process! > > end > > > > > #==============================================================================> > # Program variables > > > #------------------------------------------------------------------------------- > > src_filepath = ARGV.flags.srcfilepath > > src_file = File.basename(src_filepath) > > > > dst_filepath = ARGV.flags.dstfilepath > > dst_dir = File.basename(dst_filepath) > > > > repo_dir = "/home/file_repository/" > > repo_filepath = repo_dir + src_file > > > > sftp_server = "ftp.test.com" *#Not a real server or credentials* > > sftp_user = "user" > > sftp_pass = "password" > > > > > #==============================================================================> > # Functions > > > #------------------------------------------------------------------------------- > > > > def download_from_sftpserver(remote_filepath, sftpaddr, sftpuser, sftppass, > local_filepath) > > puts "Connecting to remote SFTP server " + sftpuser + "@" + > sftpaddr.to_s > > Net::SSH.start(sftpaddr, sftpuser, sftppass) do |ssh_session| > > puts "SSH Session open, starting SFTP." > > Net::SFTP::Session.new(ssh_session) do |sftp_session| > > puts "SFTP Session open, connecting." > > sftp_session.connect > > puts "Logged into SFTP server, downloading file: " + > remote_filepath > > *sftp_session.get_file(remote_filepath, > local_filepath)* > > puts "Download finished, logging out." > > end > > end > > end > > > > > > > #==============================================================================> > # Main Program > > > #------------------------------------------------------------------------------- > > > > download_from_sftpserver(src_filepath, sftp_server, sftp_user, sftp_pass, > repo_filepath) > > > > if File.exist?(repo_filepath) > > FileUtils.cp(repo_filepath, dst_filepath) > > if File.exist?(dst_filepath) > > puts "File delivery successful: " + dst_filepath > > puts "Encrypting repository copy..." > > repo_encrypt_file(repo_filepath) > > puts "Removing unencrypted file." > > File.delete(repo_filepath) > > puts "Job success - Exit 0" > > exit 0 > > else > > puts "Cannot deliver file to destination: " + dst_filepath > > puts "Job failure - Exit 2" > > exit 2 > > end > > else > > puts "Cannot find repository file: " + repo_filepath > > puts "Job failure - Exit 1" > > exit 1 > > end > > > > > #==============================================================================> > # The END > > > #==============================================================================> > > > > > Does anyone have any ideas? > > > > Thanks in advance for any help anyone is able to offer! > > > > Jeff > > > > Jeffery Smith - Server Administrator - jeffsmith at dcu.org > > Digital Federal Credit Union - www.dcu.org > > 508-263-6851 desk | 774-245-7940 cell | 866-383-9879 fax > > > > > > _______________________________________________ > Net-ssh-users mailing list > Net-ssh-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/net-ssh-users >-- Kyle Rabe, I.T. Specialist Mass Street Music 1347 Massachusetts Street Lawrence, KS 66044 785-843-3535 800-747-9980 www.massstreetmusic.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/net-ssh-users/attachments/20081021/d6c43724/attachment.html>
Jeffery Smith
2008-Oct-22 06:15 UTC
[Net-ssh-users] Ruby/Net-SSH - new error when downloading file
Kyle,
I just wanted to let you know that I finally managed to get around the
problem by completely removing Ruby from my system and reinstalling.
After that, I tried your suggestion again and it works great. Thank you
very much!!
Jeff
From: net-ssh-users-bounces at rubyforge.org
[mailto:net-ssh-users-bounces at rubyforge.org] On Behalf Of Kyle Rabe
Sent: Tuesday, October 21, 2008 8:09 AM
To: net-ssh-users at rubyforge.org
Subject: Re: [Net-ssh-users] Ruby/Net-SSH - new error when downloading
file
Jeff,
I never had much luck using Net::SSH and then Net::SFTP for file
uploads/downloads. If it would work for you, you could try a simpler
approach:
-----------------------------------
require ''net/sftp''
Net::SFTP.start(host, user, ...) do |sftp|
sftp.download source_file, destination_file
end
-----------------------------------
I realize that this doesn''t really help you understand your error, but
it might help you get the job done anyway.
-Kyle
On Mon, Oct 20, 2008 at 4:46 PM, Jeffery Smith <jeffsmith at dcu.org>
wrote:
Greeting all,
Sorry to send this twice...I just realized I did not put a subject line
(which I find personally annoying). So I am resending with a subject
line. Sorry for the redundancy.
I am stumped and I am hoping someone can help me out. I have been
running into an error when trying to download a file via SFTP. The
script I am using had been working until last week. I am still
searching for anything that might have been updated on my system, but
have had no luck.
This is the error:
$ ./get-sftpfile.rb -srcfilepath /remotedir/file.txt -dstfilepath
/localdir/file.txt
Connecting to remote SFTP server username at ftp.test.com
SSH Session open, starting SFTP.
SFTP Session open, connecting.
Logged into SFTP server, downloading file: /remotedir/file.txt
/usr/lib/ruby/1.8/net/sftp/operations/abstract.rb:78:in `do_status'':
Net::SFTP::Operations::StatusException (8, "The request is not
supported. ") (Net::SFTP::Operations::StatusException (8, "The request
is not supported. "))
from /usr/lib/ruby/1.8/net/sftp/session.rb:221:in `do_status''
from
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `to_proc''
from /usr/lib/ruby/1.8/net/sftp/protocol/01/impl.rb:92:in
`call''
from /usr/lib/ruby/1.8/net/sftp/protocol/01/impl.rb:92:in
`call_on_status''
from /usr/lib/ruby/1.8/net/sftp/protocol/03/impl.rb:37:in
`do_status''
from /usr/lib/ruby/1.8/net/sftp/protocol/01/impl.rb:189:in
`dispatch''
from /usr/lib/ruby/1.8/net/sftp/protocol/driver.rb:189:in
`do_data''
from
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `to_proc''
... 31 levels...
from /usr/lib/ruby/1.8/net/ssh.rb:47:in `new''
from /usr/lib/ruby/1.8/net/ssh.rb:47:in `start''
from ./get-sftpfile.rb:107:in `download_from_sftpserver''
from ./get-sftpfile.rb:131
The script is extremely simple. I''ve included it below.
get-sftpfile.rb:
#!/usr/bin/ruby
#=============================================================================
# Required modules
#-----------------------------------------------------------------------
--------
require ''rubygems''
require ''active_support''
require ''zip/zip''
require ''net/ssh''
require ''net/sftp''
require ''fileutils''
require ''ftools''
require ''find''
require ''optiflag''
module FTPtransferOptions extend OptiFlagSet
flag "srcfilepath" do
description "Full path to source file on SFTP server"
end
flag "dstfilepath" do
description "Full path to local destination for downloaded
file"
end
and_process!
end
#=============================================================================
# Program variables
#-----------------------------------------------------------------------
--------
src_filepath = ARGV.flags.srcfilepath
src_file = File.basename(src_filepath)
dst_filepath = ARGV.flags.dstfilepath
dst_dir = File.basename(dst_filepath)
repo_dir = "/home/file_repository/"
repo_filepath = repo_dir + src_file
sftp_server = "ftp.test.com" #Not a real server or credentials
sftp_user = "user"
sftp_pass = "password"
#=============================================================================
# Functions
#-----------------------------------------------------------------------
--------
def download_from_sftpserver(remote_filepath, sftpaddr, sftpuser,
sftppass, local_filepath)
puts "Connecting to remote SFTP server " + sftpuser +
"@" +
sftpaddr.to_s
Net::SSH.start(sftpaddr, sftpuser, sftppass) do |ssh_session|
puts "SSH Session open, starting SFTP."
Net::SFTP::Session.new(ssh_session) do |sftp_session|
puts "SFTP Session open, connecting."
sftp_session.connect
puts "Logged into SFTP server, downloading file:
"
+ remote_filepath
sftp_session.get_file(remote_filepath,
local_filepath)
puts "Download finished, logging out."
end
end
end
#=============================================================================
# Main Program
#-----------------------------------------------------------------------
--------
download_from_sftpserver(src_filepath, sftp_server, sftp_user,
sftp_pass, repo_filepath)
if File.exist?(repo_filepath)
FileUtils.cp(repo_filepath, dst_filepath)
if File.exist?(dst_filepath)
puts "File delivery successful: " + dst_filepath
puts "Encrypting repository copy..."
repo_encrypt_file(repo_filepath)
puts "Removing unencrypted file."
File.delete(repo_filepath)
puts "Job success - Exit 0"
exit 0
else
puts "Cannot deliver file to destination: " +
dst_filepath
puts "Job failure - Exit 2"
exit 2
end
else
puts "Cannot find repository file: " + repo_filepath
puts "Job failure - Exit 1"
exit 1
end
#=============================================================================
# The END
#=============================================================================
Does anyone have any ideas?
Thanks in advance for any help anyone is able to offer!
Jeff
Jeffery Smith - Server Administrator - jeffsmith at dcu.org
Digital Federal Credit Union - www.dcu.org
508-263-6851 desk | 774-245-7940 cell | 866-383-9879 fax
_______________________________________________
Net-ssh-users mailing list
Net-ssh-users at rubyforge.org
http://rubyforge.org/mailman/listinfo/net-ssh-users
--
Kyle Rabe, I.T. Specialist
Mass Street Music
1347 Massachusetts Street
Lawrence, KS 66044
785-843-3535
800-747-9980
www.massstreetmusic.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/net-ssh-users/attachments/20081022/d404b11e/attachment-0001.html>