in reply to execution of command inside for loop fails
If you add use strict; use warnings; at the beginning of your script, Perl will tell you what you are doing wrong.
UPDATE: I cannot test this but I guess you need a chomp. Here is how I would write it:
use strict; use warnings; sub ReadPolicies { my $type = shift; my @Policies = `/opt/OV/bin/opctemplate -l | grep -i $type | awk ' +{print \$2}'`; return @Policies; } for( ReadPolicies( "DBSPI" ) ){ chomp; # not sure this is required.... my $cmd = "/opt/OV/bin/opctemplate -e $_"; print "$cmd\n"; my $output= `$cmd`; print "$output\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: execution of command inside for loop fails
by kaka_2 (Sexton) on Oct 04, 2013 at 10:41 UTC | |
by kaka_2 (Sexton) on Oct 04, 2013 at 11:03 UTC |
In Section
Seekers of Perl Wisdom