cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
930
Views
5
Helpful
3
Replies

ASR9000 perl scripting in the shell environment

r.tostini
Level 1
Level 1

Hi everybody,

I am writing a perl embedded script in order to get information about pseudowires.

I need to get the output of this ksh command: l2vpn_show -d 0x1 | grep -E "(Group.*XC)"

The problem is that when I execute this command by the shell CLI  it works. If I try to make it run by a perl program it faults, probably because the | (pipe) char is not execute.

The line I write is:

my $cli_output = `l2vpn_show -d 0x1 | grep -E "(Group.*XC)"`;

It faults even this command:

my $cli_output = `l2vpn_show -d 0x1 | grep Group`;

Any hint to help me?

 

Regards

Raffaele Tostini

 

3 Replies 3

Alexei Kiritchenko
Cisco Employee
Cisco Employee

Hi Raffaele,

Perl itself is not good with pipes. Parce the $cli_output inside your script for a required matching pattern.
Regards,
Alex.

Which language can you suggest me as a best way to use ?

 

Thanks

Raffaele

you can use perl and ksh scripting and officially supported EEM (with TCL). My idea was not to change to another language but to show that in perl itself it is not straight forward to pipe commands from shell and if there is a need to get specific lines from $cli_output  then you parce this variable by using perl like

 

my $cli = `l2vpn_show -d 0x1` ;

my @lines = split /\n/, $cli;
foreach my $line( @lines ) {
   if ($line =~ /Group.*XC/) {
      print $line . "\n";
   }
}

Regards,
/A