Skip Menu |

This queue is for tickets about the Net-SCP CPAN distribution.

Report information
The Basics
Id: 25312
Status: open
Priority: 0/
Queue: Net-SCP

People
Owner: Nobody in particular
Requestors: dreamg [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: 0.07



Subject: Patch for different port use
Find a patch to enable the module handling of ports different then standard SSH (22).
Subject: Net_SCP.patch
--- Net/SCP.pm 2007-03-07 02:53:28.000000000 +0100 +++ /usr/local/share/perl/5.8.4/Net/SCP.pm.bak 2004-03-03 09:44:55.000000000 +0100 @@ -31,9 +31,9 @@ #allows user to type a password on tty #OO interface - $scp = Net::SCP->new( "hostname", port, "username" ); + $scp = Net::SCP->new( "hostname", "username" ); #with named params - $scp = Net::SCP->new( { "host"=>$hostname, "port"=>$port, "user"=>$username } ); + $scp = Net::SCP->new( { "host"=>$hostname, "user"=>$username } ); $scp->get("filename") or die $scp->{errstr}; $scp->put("filename") or die $scp->{errstr}; #tmtowtdi @@ -41,7 +41,7 @@ $scp->scp($source, $destination); #Net::FTP-style - $scp = Net::SCP->new("hostname", port); + $scp = Net::SCP->new("hostname"); $scp->login("user"); $scp->cwd("/dir"); $scp->size("file"); @@ -74,11 +74,10 @@ my($src, $dest, $interact) = @_; my $flags = '-p'; $flags .= 'r' unless &_islocal($src) && ! -d $src; - my $port = '-P '.$self->{'port'}; my @cmd; if ( ( defined($interact) && $interact ) || ( defined($self->{interact}) && $self->{interact} ) ) { - @cmd = ( $scp, $flags, $port, $src, $dest ); + @cmd = ( $scp, $flags, $src, $dest ); print join(' ', @cmd), "\n"; unless ( &_yesno ) { $self->{errstr} = "User declined"; @@ -86,7 +85,7 @@ } } else { $flags .= 'qB'; - @cmd = ( $scp, $flags, $port, $src, $dest ); + @cmd = ( $scp, $flags, $src, $dest ); } my($reader, $writer, $error ) = ( new IO::Handle, new IO::Handle, new IO::Handle ); @@ -144,11 +143,10 @@ =item new HOSTNAME [ USER ] | HASHREF This is the constructor for a new Net::SCP object. You must specify a -hostname and port, and may optionally provide a user. Alternatively, you may pass a +hostname, and may optionally provide a user. Alternatively, you may pass a hashref of named params, with the following keys: host - hostname - port - port user - username interactive - bool cwd - current working directory on remote server @@ -164,7 +162,6 @@ } else { $self = { 'host' => shift, - 'port' => shift, 'user' => ( scalar(@_) ? shift : '' ), 'interactive' => 0, 'cwd' => '', @@ -231,7 +228,7 @@ ( new IO::Handle, new IO::Handle, new IO::Handle ); $writer->autoflush(1); my $pid = sshopen3( $host, $writer, $reader, $error, - '-p '.$self->{'port'}, '/bin/mkdir', '-p', shell_quote($directory) ); + '/bin/mkdir', '-p ', shell_quote($directory) ); waitpid $pid, 0; if ( $? >> 8 ) { chomp(my $errstr = <$error>); @@ -263,7 +260,7 @@ $writer->autoflush(1); #sshopen2($host, $reader, $writer, 'wc', '-c ', shell_quote($file) ); my $pid = - sshopen3($host, $writer, $reader, $error, '-p '.$self->{'port'}, 'wc', '-c ', shell_quote($file) ); + sshopen3($host, $writer, $reader, $error, 'wc', '-c ', shell_quote($file) ); waitpid $pid, 0; if ( $? >> 8 ) { chomp(my $errstr = <$error>);
another port patch from Harrison Page harrison@hanford.org I modified Net::SCP this afternoon and added the following simple features: SCP->port ("8080") method will set the remote port to something other than the default. SCP->scp_path ("...") method allows one to specify an alternate path to scp. A diff against the release 0.06 has been provided. If this doesn't work for you, I can provide my changes in another form, assuming you want them at all :-) The entire file is here: http://hanford.org/SCP.pm.txt Output from diff follows. I hope this is of use to you, Harrison Page 35,36d34 < #more named params < $scp = Net::SCP->new( { "port"=>"8080" } ); 45,46d42 < #optional < $scp->port("8080"); 77,78c73,74 < my @flags = ( '-p' ); < $flags[0] .= 'r' unless &_islocal($src) && ! -d $src; --- Show quoted text
> my $flags = '-p'; > $flags .= 'r' unless &_islocal($src) && ! -d $src;
82,83c78 < push @flags, '-P' . $self->{'port'} unless ! $self->{'port'}; < @cmd = ( $scp, @flags, $src, $dest ); --- Show quoted text
> @cmd = ( $scp, $flags, $src, $dest );
90,92c85,86 < $flags[0] .= 'qB'; < push @flags, '-P' . $self->{'port'} unless ! $self->{'port'}; < @cmd = ( $scp, @flags, $src, $dest ); --- Show quoted text
> $flags .= 'qB'; > @cmd = ( $scp, $flags, $src, $dest );
157d150 < port - port number of remote sshd 171,172d163 < 'port' => 0, < 'scp_path' => $scp, 303,325d293 < < =item scp_path < < Set path to scp, default "scp". < < =cut < < sub scp_path { < my ($self, $path) = @_; < $self->{'scp_path'} = $path; < $scp = $path; < } < < =item port < < Set port. < < =cut < < sub port { < my ($self, $port) = @_; < $self->{'port'} = $port; < }
another port patch from Leo Eraly <leo@kangaroot.net> Hi, I wrote a small patch for Net::SCP to supply also a port number when scp'ing to a remote machine. Maybe you can put it in the next release? Kind regards, -- ------------------------------------------------------------------------ Leo Eraly Kangaroot Linux Solutions System Adminstrator / Developer Grote Steenweg 91 leo@kangaroot.net 2600 Berchem Tel: +32 3 286 17 10 Belgium Fax: +32 3 281 23 49 PGP/GnuPG key: 1024D/F05EED4E Key available at wwwkeys.pgp.net ------------------------- http://www.kangaroot.net ---------------------
--- SCP.pm 2005-04-20 14:30:32.000000000 +0200 +++ /usr/share/perl5/Net/SCP.pm 2005-04-20 14:23:50.000000000 +0200 @@ -71,7 +71,7 @@ sub scp { my $self = ref($_[0]) ? shift : {}; - my($src, $dest, $interact) = @_; + my($src, $dest, $interact , $port) = @_; my $flags = '-p'; $flags .= 'r' unless &_islocal($src) && ! -d $src; my @cmd; @@ -85,7 +85,15 @@ } } else { $flags .= 'qB'; - @cmd = ( $scp, $flags, $src, $dest ); + if( ( defined($port) ) || ( defined($self->{port})) ) { + if(defined($self->{port})) { + $port = $self->{port}; + } + + $flags .= "P$port"; + } + + @cmd = ( $scp, $flags, $src, $dest ); } my($reader, $writer, $error ) = ( new IO::Handle, new IO::Handle, new IO::Handle ); @@ -150,7 +158,8 @@ user - username interactive - bool cwd - current working directory on remote server - + port - ssh port on remote server + =cut sub new { @@ -165,6 +174,7 @@ 'user' => ( scalar(@_) ? shift : '' ), 'interactive' => 0, 'cwd' => '', + 'port' => 22, }; } bless($self, $class);