in reply to Double prompt in Net::Telnet
If you can't come up with a single regular expression to match all the prompts your different devices use, you might consider adding a prompt recognizing regular expression to your device configuration:
my %devices = ( 'foo' => { URL => '1.2.3.4', UID => 'bob', PWD => 'b0bzP@55w0rLD', promptRex => qr/[\$%#>] $/, statusCheckCmd => 'hello' }, 'bar' => { URL => '4.3.2.1', UID => 'joe', PWD => '533KR175@uc3', promptRex => qr/[A-Z]:> /, statusCheckCmd => 'world' }, ); for my $dev (keys %devices) { my $DEV = new Net::Telnet(Timeout=>10, Prompt=>$devices{$dev}{promp +tRex}); $DEV->open($devices{$dev}{URL}); $DEV->login($devices{$dev}{UID}, $devices{$dev}{PWD}); my @status = $DEV->cmd($devices{$dev}{statusCheckCmd}); }
I don't recall ever using Net::Telnet, but it looks like you could do it this way...
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|