Here's a snippet of code. It will be used to iterate through a cluster of machines
and bounce apache if needed. For now, a test command...

foreach my $server (@cluster) {
         my $s=Net::Telnet->new(Host=>$server,Input_log=>'telnet.txt');
         my $string='uname -n';
        $s->login(Name=> $user,
                Password=>$pass,
                Prompt=>'/root\@.*/',
                Timeout=>4) || die $s->errmsg, "\n";
        my @results=$s->cmd(String=>$string,Prompt=>'/root\@.*/') || warn $s->errmsg
,"\n";

        print "@results\n";
        $s->close();
        }

Here's the thing: the @results array only gives me the return value of the command,
which is 1! In a scalar context it is supposed to do this, but in list it's supposed
to print the output of your command, one line at a time. Am I missing something??
I'm just getting a bunch of 1s printed.

By the way, the following works (in place of the cmd() method), but it's not nearly
as clean:

 $s->print($string);
        my ($line, $match)=$s->waitfor('/root\@.*/');
        print "This is the return: $line\n";
          
Any ideas are appreciated. I need this thing to work, as I'm the one who has to
bounce apache on 15 servers by hand!

Matt C.

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

Reply via email to