Bonjour
Not many answers, so...
Am Montag, 4. April 2005 21.16 schrieb gui:
> hello,
>
> I'm making a simple script that's supposed to update a certain number of
> boxes, spread around the area.
> my script is supposed to to connect to every hosts (via a file named
> "hosts") using ssh, launch wget to retrieve the patch update, and
> install it.
> Things work fine for the first host of the list. But can never get
> beyong that. I get a "Net::SSH: Can't bind socket to port 1023: Adresse
> d�j� utilis�e at ./test_ssh.pl line 46" message.
>
> my question is, how can I unbind the socket used by Net::SSH::Perl ?
>
> here's part of my code:
>
> use strict;
> use Net::SSH::Perl;
>
> my ($patchurl,$stout,$sterr,$exit,$ssh);
> my @ids = "$ENV{HOME}/.ssh/id_rsa";
>
> my %params = (
> 'protocol' => 2,
> 'identity_files' => [EMAIL PROTECTED],
> );
>
> $patchurl = push @ARGV
>
> open HOSTS, "hosts" or die "je n'ai pas r�ussi � ouvrir le fichier hosts
>
> : $!";
>
> while(<HOSTS>){
>
> (...)
>
> $ssh = Net::SSH::Perl->new($_, %params);
> $ssh->login("root");
> ($stout,$sterr,$exit) = $ssh->cmd("wget -q $patchurl");
>
> (...)
> }
>
>
> thanks
I don't see the exact reason. But after having a look in the code (Perl.pm,
sub _create_socket, which tries ports from 1023 down to 512 to bind to),
maybe the ssh object is not destroyed between the loops. You could try:
** define $ssh as my variable within the loop (not outside as currently)
** put the code within the loop in a separate block, containing the
my-Definition of $ssh
** use "undef $ssh" at the end of the loop (still within it of course)
** Insert some diagnostic code at the beginning of the loop that
a) examines the $ssh object before the second "loop run" and/or
b) sleeps for e.g. a minute, so that you can look whats happening with the
bound port (netstat -neat from cmdline)
I don't have the Modules installed, so I didn't made tests, sorry.
joe
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>