Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I search for a string in a log file????? 1

Status
Not open for further replies.

dshaw21369

Programmer
Jul 8, 2002
64
I'm wanting search for the string "Rollback", if I see the string send an email with a message.


#!/usr/bin/perl

@XML_COBOL_LOG =();
$Rollback ="Rollback";
#Open Debug
unless (open (Debug,">/export/home/egate/Perl_Development/Debug.txt"))
{
print "Debug.txt does not exist\n";
}
#Open bobConvert_XML_to_Cobol.log
unless (open (XML_COBOL_LOG,&quot;</export/home/egate/egate/client/logs/bobConvert_XML_to_Cobol.log&quot;))
{
print Debug &quot;bobConvert_XML_to_Cobol.log does not exist\n&quot;;
}
(@XML_COBOL_LOG)=<XML_COBOL_LOG>;

close Debug;
close XML_COBOL_LOG;

Thanks for your help!
 
Take out the line:

(@XML_COBOL_LOG)=<XML_COBOL_LOG>;

and insert:
Code:
while(<XML_COBOL_LOG>){
  if( /$Rollback/ ){
     print Debug &quot;$Rollback on line $.\n&quot;; 
  }  
}

See if that does what you want.

--jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top