Re: Syntax Problem...

From: Clifford Bracht (beaton_at_franklincollege.edu)
Date: 01/09/04


Date: 9 Jan 2004 12:14:35 -0800


"Paul Boardman" <Paul.E.Boardman@umist.ac.uk> wrote in message news:<3ffe6eb4@news.umist.ac.uk>...
> "Clifford Bracht" <beaton@franklincollege.edu> wrote in message
> news:41e4115.0401081224.315618ae@posting.google.com...
> > I'm tring to write a script that verifies if the time of the last
> > modification is more recent than the time of the last access.
>
> <snip code>
>
>> Why are you opening the file and reading through it?
>
>
First off, Thank you to everyone for the suggestions and help.
I figured out a few of my mistakes shortly after I posted my message
and after working on the coding some I have come up with this:

#!/usr/bin/perl -w
#perl -w
$filename = "C:/temp/test.txt";
Set_File();
 
sub Set_File
{
 
open (FILEHANDLE, "<$filename") || die "Cannot open $filename,
err=\"$!\"\n";

if ($filename ne " \n")
  {
  $mtime = (stat ($filename))[9] || die "Sorry, cannot stat! \n";
  Check_Mod();
  }
}

sub Check_Mod
{
while(1)
 {
 $mtime_2 = (stat ($filename))[9] || die "Sorry, cannot stat! \n";
   
   #View the two Mod times for test purposes.
   print "previous_mtime = $mtime and mtime = $mtime_2 \n";

 #Test to see if Modification have been made to file
   if ($mtime_2 ne $mtime)
  {
        print "$filename has been modified.! \n";
        Set_File();
  }
  else
  {
          print "$filename is OK. \n";
  }

print "$filename is done testing. \n";
 #sleep 60;
  }
}

I have tested it and when I change the file it sends the correct
message and then runs through a new loop.

But it runs in an infinite loop that I would only like to run every 60
seconds, but when I put the code the line:
sleep 60; the script will not output anything??? Does anyone have any
suggestions. Do I have the sleep function in the correct place, or do
I need to go about this in a differe way??

I also don't know if I used proper Perl practices by calling the sub
routines the way that I did at the beginning and in the while loop, so
that might contribute to the problem?? Thanks



Relevant Pages

  • Re: Loop for only 10 cycles
    ... I will not comment on other issues, but altered your script ... I'm concerned that it will get caught in a never ending loop ... > Drive, intDrive, intTry, intTryMax ... > Sub QDRIVE ...
    (microsoft.public.windows.server.scripting)
  • Re: reload the vbscript itself within a vbscript
    ... Loop ... >> input is less than 1 character long, the script will reload. ... >> However, the problem is that it is sub procedure, the sInputUserDept is ...
    (microsoft.public.scripting.vbscript)
  • Re: How to remotely activate Ctrl-C ?
    ... I read about that Sleep function and I am a little confused. ... The time delay function I am using looks like that: ... Public Sub DelayTimer ... Loop ...
    (microsoft.public.vb.general.discussion)
  • RE: OWA usage analysis script
    ... I'll just keep this script updated on PSC ... > sub processfile ... > Hits Long, TS DateTime)" ...
    (microsoft.public.exchange2000.clients)
  • Loop for only 10 cycles
    ... The script below works great for mapping over a VPN and uses an .htm page to ... I'm concerned that it will get caught in a never ending loop when ... it's mapping the drives if it's unable to find the drive. ... Sub QDRIVE ...
    (microsoft.public.windows.server.scripting)