tsk1979 has asked for the wisdom of the Perl Monks concerning the following question:

I am using Net::Telnet module with perl 5.8.5 In that I use the code
$t->cmd("cd $repositery/$arglist[$i]"); @uname_string = $t->cmd("uname -a"); print "We got the uname @uname_string\n"; The array @uname_string has nothing. However if I do a print $t->cmd("uname -a"); it prints the uname I also tried ($uname_string) = $t->cmd("uname -a"); @uname_string = $t->cmd('uname -a');
I also took the example from cpan where I do
@uname_string = $t->cmd("who");
but when I do print @uname_string, I get nothing. any ideas?

Replies are listed 'Best First'.
Re: net::telnet not behaving as expected
by wazoox (Prior) on Mar 22, 2006 at 14:03 UTC
    You should try
    my $unamestring = $t->cmd("uname -a");
    instead. The example in the Net::Telnet documentation uses a command (who) that returns several lines, that's why it's using an array. But you don't need to, because you're running a command that returns only one line.
    By the way, would you have used "use strict" and "use warnings" ( as everybody should get used to ) you'd certainly receive an appropriate warning.
      I tried $unamestring also, it got the value 1. I think it took it in scalar context
        then try use Data::Dumper; print dumper \@unamestring and check what's happening.