# Get the all the values for current time ($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear, $IsDST) = localtime(time); $RealYear = $Year + 1900; #Create proper format for year $RealMonth = $Month + 1; #Add 1 to month because PERL starts @ 0 # Add leading "0" to Miniute if less than 10 if($Minute < 10) { $Minute = "0". $Minute; } # Create a Log File open (fail_log,">>faillog.txt"); # Create Router Re-Configuration script run command $rtr_cfg="wscript.exe rtr-telnet.vbs"; # Create a var that holds the string to be found in the "gethttpbuff" results $search=""; # Create & run "GETHTTP.EXE" command. Redirect output to "gethttpbuff.txt" $gethttp="gethttp.exe http://www.blahblahblah.com>gethttpbuff.txt"; system($gethttp); #it seems like the code below is what doesn't work right. if (&Search_Buff($decide == "1")){ &Site_Up; } else { &Site_Down; } # Sub to search gethttpbuff.txt for a string & return 0 or 1 sub Search_Buff { # Open hethttpbuff.txt file, create an array with the data & close file. End if file is locked. open (gethttpbuff, "gethttpbuff.txt") || die("Could not open file!"); @array = ; close(gethttpbuff) # If search string is found make var equal to "1". If the search string is not found make var equal to "0" foreach $line (@array) { if ($line =~ /$search/) { $decide = "1"; } else { $decide = "0"; } } sub Site_Up { # site is up print fail_log ($Hour); print fail_log (":"); print fail_log ($Minute); print fail_log ("-and all is well on "); print fail_log ($RealMonth); print fail_log ("-"); print fail_log ($Day); print fail_log ("-"); print fail_log ($RealYear); print fail_log ("\r\n"); } sub Site_Down { # Site is down print fail_log ("Blahblahblah.com has gone down! "); print fail_log ($Hour); print fail_log (":"); print fail_log ($Minute); print fail_log (" "); print fail_log ($RealMonth); print fail_log ("-"); print fail_log ($Day); print fail_log ("-"); print fail_log ($RealYear); print fail_log ("\r\n"); system($rtr_cfg); } }