Leon Rosenstein wrote:
>
> Hi again everyone,
Hello,
> In a script I have a section that looks like this
>
> #Finally we have to load all extensible counters
> system("lodctr faxperf.ini") or die "sorry couldn't do $!";
> system("lodctr dnsperf.ini") or die "sorry couldn't do $!";
> system("lodctr esentperf.ini") or die "sorry couldn't do $!";
> system("lodctr iasperf.ini") or die "sorry couldn't do $!" ;
> system("lodctr dnsperf.ini") or die "sorry couldn't do $!";
> system("lodctr msdtcprf.ini") or die "sorry couldn't do $!";
> system("lodctr ntdsctrs.ini") or die "sorry couldn't do $!";
> system("lodctr ntfrsrep.ini") or die "sorry couldn't do $!";
> system("lodctr perfci.ini") or die "sorry couldn't do $!";
> system("lodctr perffilt.ini") or die "sorry couldn't do $!";
> system("lodctr perfwci.ini") or die "sorry couldn't do $!";
> system("lodctr pschdperf.ini") or die "sorry couldn't do $!";
> system("lodctr rasctrs.ini") or die "sorry couldn't do $!";
> system("lodctr rsvp.ini") or die "sorry couldnt do $!";
> print "all done!!!!";
You are not using system() properly there.
perldoc -f system
[snip]
The return value is the exit status of the program
as returned by the `wait' call. To get the actual
exit value divide by 256. See also the exec entry
elsewhere in this document.
[snip]
@args = ("command", "arg1", "arg2");
system(@args) == 0
or die "system @args failed: $?"
You can check all the failure possibilities by
inspecting `$?' like this:
$exit_value = $? >> 8;
$signal_num = $? & 127;
$dumped_core = $? & 128;
When the arguments get executed via the system
shell, results and return codes will be subject to
its quirks and capabilities. See the section on
"`STRING`" in the perlop manpage and the exec
entry elsewhere in this document for details.
> Sometimes one of the commands fail for a reason I am not sure of (it will
> fail at line 29 but when I rerun the script it will fail at 35 then it will
> fail at 40 then it wont fail at all. I also notice that when I actually
> manually enter the commands through the command line it sometimes doesnt
> take either.
>
> Dumb question but does anyone have a clue how I could write a loop to loop
> through this and rerun it if it doenst complete.
>
> I was thinking of writing a loop using until. Something like until we say
> all done keep running the script.
>
> Since i am new to programming all together (first language and all) it is
> sometimes hard to get into the "mentality of a programmer".
Something like this should work:
#Finally we have to load all extensible counters
my @files = qw/faxperf.ini dnsperf.ini esentperf.ini iasperf.ini
dnsperf.ini msdtcprf.ini ntdsctrs.ini ntfrsrep.ini
perfci.ini perffilt.ini perfwci.ini pschdperf.ini
rasctrs.ini rsvp.ini/;
while ( @files ) {
my $file = shift @files;
if ( system 'lodctr', $file ) {
warn "Cannot run 'lodctr $file' $?";
push @files, $file;
}
}
print "all done!!!!\n";
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]