On May 31, Lance Prais said:
>There are a couple of problems that I am having:
>1. The script is never ending. I though "while (1)" is the right way to
>do this.
The script never ends because you're using 'while (1) { ... }'. That goes
on forever. You'll have to tell Perl to stop manually.
>2. Every time it runs I get the follow error it never opens another
>outlook.txt file. so the script continues to read the same txt over and
>over again.
> The process cannot access the file because
> it is being used by another process.
Perhaps you should consider CLOSING filehandles that you open.
>#/usr/bin/perl
>
>while (1)
>{
># RUN EVERY 10 SECONDS
> sleep 10;
> $cmd="";
That's pointless.
> $cmd = '..\\..\\srvrmgr /g apollo.ts.checkpoint.com /e CHK_ENT_PRD /s
>CHK_SBL_PRD /u xxxxxxxxx /p xxxxxxxxxx /c "list tasks for server CHK_SBL_PRD
>component Email Manager" > ..\\..\\outlook.txt';
> $result = `$cmd`; # note back-ticks
Why not just
$result = `..\..\srvrmgr /g ...`;
Why are you using a variable?
>
># OPEN A FILE WITH THE FILEHANDLER
> open OUTLOOK, "+<..\\..\\outlook.txt" or die "Cannot open email manager
Why are you using "+<" instead of just "<"? You're not WRITING to the
file, so there's no need for the "+".
>$!\n";
>
># THIS WILL PUT YOU AT ROW 23.----
> for(my $i=0; $i<22; $i++){<OUTLOOK>};
> $_=<OUTLOOK>;
You should close the filehandle now.
> my $line=$_;
This is pointless.
> print "substr($line, 106, 22)\n";
Do you really want to have substr(...) inside the quotes?
print substr($line, 106, 22), "\n";
># OPEN LOG TO TRACK
> open (APPEND, ">>siebel_mail.log") or die "$! error trying to append";
> print APPEND "substr($line, 106, 22)\n";
You should close the filehandle now.
>}
Here's a rewrite:
#!/usr/bin/perl -w
use strict;
open MAIL_LOG, ">> siebel_mail.log" or
die "can't append to siebl_mail.log: $!";
# do this 6 times
for (1 .. 6) {
open OUTPUT, '..\\..\\srvrmgr /g apollo.ts.checkpoint.com /e CHK_ENT_PRD /s
CHK_SBL_PRD /u xxxxxxxxx /p xxxxxxxxxx /c "list tasks for server CHK_SBL_PRD component
Email Manager" |' or
die "can't run srvrmgr: $!";
<OUTPUT> for 1 .. 22; # skip first 22 lines of output
my $line = substr <OUTPUT>, 106, 22;
close OUTPUT;
print $line, "\n";
print MAIL_LOG $line, "\n";
sleep 10;
}
close MAIL_LOG;
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]