in reply to Re: Re: Re: Running or not running
in thread Running or not running

Ok this is what I did
#! c:\perl\bin $|++; use strict; use vars qw /%data/; $data{apps_list} = shift @ARGV; system (cls); print "\n\nPath to apps list => ". $data{apps_list}."\n"; open (LST, "$data{apps_list}") || die "$! : File was not found\n"; chomp (@{$data{Go_scripts}} = <LST>); for my $item (@{$data{Go_scripts}}) { print "\n$item\n"; system ($item); if (system() ==0) # this is incorrect { print "\n Done\n"; } else { print "Failed\n"; } }
Obviously it doesn't work because of the "if (system() ==0)" which is not correct, but the correct way of this is what I am trying to achieve!

Any Thoughts?

TIA

Replies are listed 'Best First'.
Re*5: Running or not running
by Tomte (Priest) on May 13, 2004 at 13:34 UTC

    from system:

    You can check all the failure possibilities by inspecting $? like this:
    if ($? == -1) { print "failed to execute: $!\n"; } elsif ($? & 127) { printf "child died with signal %d, %s coredump\ +n", ($? & 127), ($? & 128) ? 'with' : 'without +'; } else { printf "child exited with value %d\n", $? >> 8; }

    Do you want the following?

    system($item); # evaluate status $? according to perldoc -f above

    regards,
    tomte


    An intellectual is someone whose mind watches itself.
    -- Albert Camus