Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: execution of command inside for loop fails

by kaka_2 (Acolyte)
on Oct 04, 2013 at 10:41 UTC ( #1056863=note: print w/ replies, xml ) Need Help??


in reply to Re: execution of command inside for loop fails
in thread execution of command inside for loop fails

Thank You. adding strict and warnings was very helpful.


Comment on Re^2: execution of command inside for loop fails
Replies are listed 'Best First'.
Re^3: execution of command inside for loop fails
by kaka_2 (Acolyte) on Oct 04, 2013 at 11:03 UTC

    Here is my updated code

    sub ReadPolicies { # based on the below command it reads values in ar +ray my ($type) = @_; my @Policies = `/opt/OV/bin/opctemplate -l | grep -i $type | awk '{pri +nt \$2}'`; return (@Policies); } #MAIN My @FailoverPolicies = &ReadPolicies(DBSPI); For (my $i=0; $i < @FailoverPolicies; $i++) { my $cmd "/opt/OV/bin/opctemplate -e" . " " . "$FailoverPolicies[$i]"; my $output= `$cmd`; # here i expect this command read each value from +the array and take action, -e to enable }

    and this works fine but the problem i face is that i see so many <defunct> process on system and i think it is because first command is not completed and second also start and so one and one point this hangs.

    What can i do to ensure 2nd command executes only when first is completed in the loop.

    Thank You.

    -KAKA-

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1056863]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (16)
As of 2015-07-28 11:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (254 votes), past polls