EDIT 1 : Removed the sentence : ", well first thing first the " have to be escaped such as \"
, but" , my mistake this doesn't make sense.
EDIT 2 : Added content of $cmd
EDIT 3 : added intelligible code sample
I'm experiencing a problem when using Perl's Net::SSH::Expect module to communicate with Juniper network devices (JunOS).
There is a specific need to use double quotes in JunOS for certain commands. When I connect manually to the device, a fictive command such as : show something | match "this | that" works correctly.
When using this command through the Net::SSH::Expect module the command won't return an output at all.
Here's how the session is opened
$session = Net::SSH::Expect->new(
host => $device->{ip},
port => $port // 22,
ssh_option => $options // '',
user => $username,
password => $password,
raw_pty => 1,
timeout => $session_timeout)
and the commands are being sent using "$session->send($cmd);" , then retrieved with the before() function.
$session->send($cmd);
unless($session->waitfor($device->{promptSSH}, $cmd_timeout)) {
$logger->warn("$device->{hostname} ($device->{ip}) : SSH - Echec (Timeout) de la commande $cmd");
$data->{'timeout'} = 1; # status flag
}
@{$data->{'output'}} = $session->before();
return $data;
Where $cmd would contain as per example : show interfaces diagnostics optics | match "Laser output power |Laser receiver power"
If I don't escape the double quotes, we get this strange output
Please note that the commands are read from a simple text file in the system, here's an extract
I'm totally clueless, can anyone help me please ?
Cheers