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"; }
In reply to Re: execution of command inside for loop fails
by hdb
in thread execution of command inside for loop fails
by kaka_2
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |