Re: [Ssh-sftp-perl-users] bind socket problem
Brought to you by:
dbrobins
From: Robert L. <rla...@ao...> - 2005-04-07 15:21:05
|
On Thu, Apr 07, 2005 at 02:39:05PM +0200, guillaume dout=E9 wrote: > Things work fine for the first host of the list. But can never get=20 > beyong that. I get a "Net::SSH: Can't bind socket to port 1023: Adresse= =20 > d=E9j=E0 utilis=E9e at ./test_ssh.pl line 46" message. I had a similar problem with apache and net::sftp. I solved it by forcing the connection closed in SFTP.pm. > my question is, how can I unbind the socket used by Net::SSH::Perl ? Don't bother... Use fork. When the child process exits, the socket will (err... should) unbind. You might have to figure out how you're going to handle saving stdout, err, etc. I'd probably just write them to= =20 a log... >=20 > here's part of my code: >=20 > use strict; > use Net::SSH::Perl; >=20 > my ($patchurl,$stout,$sterr,$exit,$ssh); > my @ids =3D "$ENV{HOME}/.ssh/id_rsa"; >=20 > my %params =3D ( > 'protocol' =3D> 2, > 'identity_files' =3D> \@ids, > ); >=20 > $patchurl =3D push @ARGV >=20 > open HOSTS, "hosts" or die "je n'ai pas r=E9ussi =E0 ouvrir le fichier = hosts=20 > : $!"; >=20 > while(<HOSTS>){ >=20 > (...) if(fork) { # parent wait; } else { # child >=20 > $ssh =3D Net::SSH::Perl->new($_, %params); > $ssh->login("root"); > ($stout,$sterr,$exit) =3D $ssh->cmd("wget -q $patchurl"); } >=20 > (...) > } Good luck, Rob --=20 Robert Landrum Systems Programmer |