Hi Monks, I have to write a perl script which prints all the information related to a given username and system related errors from multiple log files.I started learning perl for this and trying my hand in it,prior to it i dont have any experience in perl scripting. i need some suggestions regarding the script. I will try to explain the requirement- 1. given a user name the script should print all the information related to that user from the log files including time stamps. 2. Should print all system related error messages like DB failover, fatal errors etc including time stamps. these are the two things for now and after that i need to enhance that further because there are so many other things to do. The log file is very big so how can i upload that file. For the first question a username given can do these things and should be checkd if it is present there- QnAModule::authenticate UPAuthModule::authenticate OTPAuthModule::authenticate this part is tricky for me and i need some suggestions for this,please provide your valuable suggestion. I just started with the formal code but the main logic is missing as i need some help.
print "The Perl Script does the User health check and system health ch +eck...\n"; print "--------------------------------------------------------------- +------\n"; # use strict; use Getopt::Std; use Getopt::Long; my($OS); $OS = $^O; # need to test @ARGV before GetOptions shifts it if (@ARGV == 0) { print "\nNo options provided, using defaults (use -h to view option +s)\n"; } GetOptions( 'h|help' => \$_help ,'u|userdata' => \$_userdata ,'s|systemdata' => \$_systemdata ,'a|authresponsecode' => \$_authresponsecode ,'o|outpur_dir' => \$_output_dir); if( $_help ) { printUsage(); # automatically exits the program } ###################################################################### +######## # Print the usage info and automatically exit ###################################################################### +######## sub printUsage() { print "\n\nUsage:"; print "\n perl MSLogStat.pl [options] [logfile1] [logfile2] ... [l +ogfile(n)]"; print "\n\nOptions:"; print "\n -h * display usage help"; print "\n -o * redirect the output to a directory"; print "\n -u * display user related data"; print "\n -a * display auth response codes"; print "\n -s * output only system related data"; print "\n"; exit; } ###################################################################### +######## # Print the authresponsecode ###################################################################### +######## sub authresponsecode () { print "AAFW_AUTH_SUCCESS = 0"; print "AAFW_AUTH_MORESTEPS = 1"; print "AAFW_AUTH_ID_NOT_FOUND = 2"; print "AAFW_AUTH_INVALID_CREDENTIAL = 3"; print "AAFW_AUTH_ACCOUNT_EXPIRED = 4"; print "AAFW_AUTH_ACCOUNT_INACTIVE = 5"; print "AAFW_AUTH_ATTEMPTS_EXHAUSTED = 6"; print "AAFW_AUTH_TOKEN_EXPIRED = 7"; print "AAFW_AUTH_CHALLENGE_EXPIRED = 8"; print "AAFW_AUTH_INVALID_REQUEST = 9"; print "AAFW_AUTH_CRED_REISSUED = 10"; print "AAFW_AUTH_INTERNAL_ERROR = 11"; print "AAFW_AUTH_UNSUPPORTED_MECH = 12"; print "AAFW_AUTH_LAST = 13"; } # redirect output to a directory: if( $_output_dir ) { # does this directory already exist? if (! -e $_output_dir) { if( $OS =~ "Win32" ) { `mkdir $_output_dir`; } else { `mkdir -p $_output_dir`; } } if (! -e $_output_dir) { die "Failed to create output directory $_output_dir\n"; } if( $_authresponsecode ) { print "Printing the Auth Response Codes"; authresponsecode(); } sub analyzeLogFile() { open(my $LOG, 'C:\aokapplication.txt') or die "$!";
the logfile is quite big so how can i upload that.or i will upload that in reply message. Thanks NT

In reply to perl script by namishtiwari

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.