janasec has asked for the wisdom of the Perl Monks concerning the following question:
issue with grep in the output of a command
I have a script that executes on a remote machine and fetched the output
The output saves in to a variable,I need to grep for a value so i can use it,the sample code is below
the $out contains the output of the cfgshow command the output in $out is$logger->info("performing ssh to the swicth"); my $ssh = Net::OpenSSH->new($ip,user=>"$username",password=>"$password +",master_opts=>[-o =>"StrictHostKeyChecking=no"]); print"$display_message\n"; $logger->info("listing the current defined configuration of the switch + using cfgshow"); my($out,$err) = $ssh->capture2("cfgshow");
i need to grep for FC_DVT into anther variable,please help on how to do it I need a variable to contain only "FC_DVT" i dont need other values2015/07/25 23:01:48 Test1:pass cfgshow Defined configuration: cfg: FC_DVT MEZZI; MEZZI1 zone: MEZZI mezzi1; mezzi2; sanblaze zone: MEZZI1 mezzi3; mezzi4; sanblaze zone: vikash_enfield 10:00:00:00:c9:a1:95:aa; 10:00:00:00:c9:a1:95:ab; 20:00:00:11:0d:34:56:00 alias: mezzi1 10:00:00:00:c9:cd:cc:6c alias: mezzi2 10:00:00:00:c9:cd:cc:6d alias: mezzi3 10:00:00:90:fa:2e:dd:9f alias: mezzi4 10:00:00:90:fa:2e:dd:a0 alias: sanblaze 20:01:00:11:0d:34:57:00 Effective configuration: cfg: FC_DVT zone: MEZZI 10:00:00:00:c9:cd:cc:6c 10:00:00:00:c9:cd:cc:6d 20:01:00:11:0d:34:57:00 zone: MEZZI1 10:00:00:90:fa:2e:dd:9f 10:00:00:90:fa:2e:dd:a0 20:01:00:11:0d:34:57:00
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: issue with grep in the output of a command
by pme (Monsignor) on Jul 25, 2015 at 12:49 UTC | |
|
Re: issue with grep in the output of a command
by CountZero (Bishop) on Jul 25, 2015 at 13:02 UTC | |
|
Re: issue with grep in the output of a command
by Laurent_R (Canon) on Jul 25, 2015 at 14:23 UTC | |
|
Re: issue with grep in the output of a command
by ww (Archbishop) on Jul 27, 2015 at 12:26 UTC |