I have a templating system that I use to create pages on my site. Recently, in talking with their tech support, we switched from normal ftp to sftp. Ever since, the code I had been using has been essentially broken. What I had before was:
sub get_ftp_object{ use strict; use Net::FTP; my $sub_hash = "my_ftp"; my $domain = $config{$sub_hash}->{'domain'}; my $username = $config{$sub_hash}->{'username'}; my $password = $config{$sub_hash}->{'password'}; #dial up the server my $ftp = Net::FTP->new( $domain, Debug => 0, Passive => 1 ) or die "Can't connect: $!\n"; $ftp->login( $username, $password) or die "Couldn't login\n"; return $ftp; }
So, I think, gosh, all I have to do is append a cap S in front of FTP, download the module, and voila. There's always a tricky part, and this one was getting Math::GMP squared away, along with the requisite C library. For others who might trod this path--including myself the next time I get hung up on it, the following command for a debian install put gmp.h where it had to be:
sudo apt-get install libgmp3-devWhat I have now gets past the use statement but not by far:
Permission denied at /usr/local/share/perl/5.22.1/Net/SFTP.pm line 62.This would be close to an analog of what I had. The say statement prints out the values that I have verified with my ISP. BTW, they think there is no reason I should not be able to transfer files.
sub get_ftp_object{ use strict; use Net::SFTP; use 5.01; my $sub_hash = "my_sftp"; my $domain = $config{$sub_hash}->{'domain'}; my $username = $config{$sub_hash}->{'username'}; my $password = $config{$sub_hash}->{'password'}; #dial up the server say "values are $domain $username $password"; my $sftp = Net::SFTP->new( $domain, Debug => 1) or die "Can't connect: $!\n"; $sftp->login( $username, $password) or die "Couldn't login\n"; return $sftp; }
It might help the local diagnosticians to show line 62 of SFTP.pm in context. I've remarked next to it and wonder if SFTP requires more to ask a server for a new object than FTP did:
# returns the new object sub init { my $sftp = shift; my %param = @_; $sftp->{debug} = delete $param{debug}; $sftp->{status} = SSH2_FX_OK; $param{ssh_args} ||= []; $param{ssh_args} = [%{$param{ssh_args}}] if UNIVERSAL::isa($param{ssh_args},'HASH'); $param{warn} = 1 if not defined $param{warn}; # default $sftp->{warn_h} = delete $param{warn} || sub {}; # false => ignor +e $sftp->{warn_h} = sub { carp $_[1] } # true => emit warning if $sftp->{warn_h} and not ref $sftp->{warn_h}; $sftp->{_msg_id} = 0; my $ssh = Net::SSH::Perl->new($sftp->{host}, protocol => 2, debug => $sftp->{debug}, @{ $param{ssh_args} }); $ssh->login($param{user}, $param{password}, 'supress_shell'); #lin +e 62 $sftp->{ssh} = $ssh; my $channel = $sftp->_open_channel; $sftp->{channel} = $channel; $sftp->do_init; $sftp; }
Alright, so there it is. I'm fishing for tips, tricks, whatever you have that pertains to getting SFTP working. It's really putting a cramp in my business to not be able to use my own site effectively. Thank you for your comment.
In reply to instantiating an SFTP object by Aldebaran
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |