perlquestion
gctaylor1
When I use Net::Telnet my command works but it also echoes the command and I want just the results. The docs for Net::Telnet talk about this and suggest using cmd_remove_mode, yet I still get the same result in my output. I've been working on this silly problem for hours. It seems so simple but I cannot figure out what I'm missing here?
<p>Here's my code:
<p>
<c>
#!/usr/bin/perl
use strict;
use warnings;
use Net::Telnet ();
my $t = new Net::Telnet (Timeout => 10,
Prompt => '/host\@user ~\/');
my ($username, $passwd) = qw(user password);
$t->open("host");
$t->login($username, $passwd);
my @distro = $t->cmd(String => "cat /etc/redhat-release",
cmd_remove_mode => '1');
print "@distro";
</c>
Which produces this output:
<c>
$ ./connect.pl
$ cat /etc/redhat-release
CentOS release 5 (Final)
</c>
<p> and I don't want the cat command.
Can anyone shed some light?
<p>
UPDATE:
<br>
Set cmd_remove_mode to the number of lines to remove such as
<c>
my @distro = $t->cmd(String => "cat /etc/redhat-release",
cmd_remove_mode => '2');
</c>
<br>
to remove two lines.