Hi,
If someone can help me out please
I wrote a perl script which opens two text files and then compares them and
spit out the difference. It is an error checking program which runs on NT
Platform. The first file has all the required processes listed and the
second file lists current running processes.
The second file is being generated at time intervals thru running a bat file
manually. When you run that batch file it generates the second text file
which has the current processes running.
I want to ask you how I can incorporate that batch file in my script so that
it can run on specified time intervals. After running the bat file the
resultant text file is going to be my second file in the script.
I want my script to kick off automatically at predefined time intervals, run
bat file and then use the text file generated by bat file as the second file
in the script.

Can someone help me on this please

Thanks
Junaid

Here is the script

use Win32;

my($snapshot, $baseline);               # Defining txt files 

# First file
$snapshot = "./secondfile.txt"; # List of Svcs currently running, should be
generated by the bat file

# Second file
$baseline = "./firstfile.txt";  # List of All Svcs which should be running

my(@arr1, @arr2, @result);  # Defining arrays
my($fld1, $fld2, $fld3, $fld4); # Defining variables for fields
my($match, $cnt, $val1, $val2, $finalresult); # Defining scalar variables
$match = "N"; 

#Open snapshot file and insert every line into @arr1
open(SNAPSHOT, $snapshot) or die "Unable to open $snapshot."; # Open the txt
file and place it in filehandle           

$cnt = 0;
while ( <SNAPSHOT> ) # Looping thru the filehandle snapshot
 {
        $arr1[$cnt] = $_;
        $cnt = $cnt + 1;
  } 
  close (SNAPSHOT); # close the filehandle snapshot

#Open baseline file and insert every line into @arr2
open(BASELINE, $baseline) or die "Unable to open $baseline."; # Open the txt
file and place it in filehandle                      

$cnt = 0;
while ( <BASELINE> ) # Looping thru the filehandle baseline
{
        $arr2[$cnt] = $_;
        $cnt = $cnt + 1;
  } 
  close (BASELINE); # close filehandle baseline

# Outer loop is for baseline file
# Inner loop is for snapshot file
# Taking one element from @arr2 (baseline) and comparing it with all the
elements in @arr1(snapshot) and 
# If their is no match then insert that name into finalresult.

$cnt = 0;
foreach $val2 (@arr2) # referring to baseline
{
        foreach $val1 (@arr1) # referring to snapshot
        {
                if ($val1 eq $val2) 
                {
                        $match = "Y";
                }
        }
        if  ($match eq "N") 
        {
                $result[$cnt] = $val2;
                $cnt = $cnt + 1;
        }

        $match = "N";
        }

$finalresult = 0; # initializing to zero
foreach $val1 (@result)
{
        $finalresult = $finalresult + 1;
}

if ($finalresult >  0 ) 
{
        print "\nList of process not running \n\n"; # If some svc is not
functioning
        foreach $val1 (@result)
        {
                ($fld1,$fld2,$fld3,$fld4) =  split(/\|/,"$val1");#
separating req fields for output
        
        }
}
else
{
        print "\nAll process are running \n"; # When all svcs are running
fine
}


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to