DavisTasar
DavisTasar

Reputation: 275

Perl Net::Telnet::Cisco Bad named parameter

I'm trying to get some scripting finished to deploy changes en masse to about 400 Cisco devices. I've got a perl script modified from MrAudit that's using Net::Telnet::Cisco and for the life of me, I can't figure out the named parameter component.

In the documentation, they have:

$ok = $obj->cmd($string);
$ok = $obj->cmd(String   => $string,
                [Output  => $ref,]
                [Prompt  => $match,]
                [Timeout => $secs,]
                [Cmd_remove_mode => $mode,]);

@output = $obj->cmd($string);
@output = $obj->cmd(String   => $string,
                    [Output  => $ref,]
                    [Prompt  => $match,]
                    [Timeout => $secs,]
                    [Cmd_remove_mode => $mode,]
                    [Normalize_cmd => $boolean,]);

And my code is:

$testString is the test command I'm running against the device, $userTest1 is an array being cast where I want the output to be stored.

$::OPENRTR->cmd(String=>$testString,[Timeout=>5,Output=>$userTest1,]);

And every single time, no matter which component I modify or try and write it a different way, I get a variation of the error:

Odd number of elements in hash assignment at(filename)
bad named parameter "ARRAY(0x2e46460)" given to Net::Telnet::Cisco::cmd() at mrAudit-TACACSMod.pl line 279

I know it has to be something simple, but it's just flying right by. Any help would be appreciated.

Upvotes: 0

Views: 364

Answers (1)

choroba
choroba

Reputation: 242103

I think the square brackets in the documentation just show the arguments are optional, you shouldn't use them in real code:

 $OPENRTR->cmd( String  => $testString,
                Timeout => 5,
                Output  => $userTest1);

Upvotes: 2

Related Questions