Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Help e-mailing last 50 lines of log file

by Abigail-II (Bishop)
on Jul 18, 2002 at 15:58 UTC ( [id://182874]=note: print w/replies, xml ) Need Help??


in reply to Help e-mailing last 50 lines of log file

Urgle. All that to send 50 lines by email? I am so glad I work on Unix. There it takes just one line, and you don't even need Perl:
$ tail -50 $log_file | mailx -s "50 lines." me@example.org

Abigail

Replies are listed 'Best First'.
Re: Re: Help e-mailing last 50 lines of log file
by Jenda (Abbot) on Jul 18, 2002 at 17:17 UTC

    Ha, ha, ha ... you are soooo funny.

    But the AnonymousMonk seems to be a little confused as well. The lengthy code does a lot of things, but there's no tailing and mailing. What is the real question? How to get the results of tail.exe? Or how to include them in the email? Or what? And why did you include the service related code?

    I think you want something like this:

    $loglines = `tail -50 $logfile`; $message = <<"*END*"; This email was generated after an error was detected, the NetRestartService.pl script was executed. Log file: $loglines *END* $msg = MIME::Lite->new( From =>'NetRestartService', To =>'Test@test.com', Cc =>'Test2@test2.com', Subject =>'Perl Script to restart remote NT Service - NetRestartServ +ice.pl', Data => message , ); $msg->send;

      Jenda

      Hi Jenda,

      Sorry for the confusion with the code above...I didn't put everything on the forum correctly. It was missing lots of code. I'm faily new at PERL and I'm learning as I go, putting bits and pieces of code together that I've obtained on the internet.

      I don't know how to put everything together. This is the first code section I want to use....The code will use "TAIL.exe" placed in the WINNT\SYSTEM32 directory. How do I get the the "TAILED" result from the "LOG1.LOG" and create a new log with that informaton. Once this is done, I need to send an email with the newly created log file. Once the email is sent the weblogic service needs to be restarted. (I want to run the scipt remotely).

      - Can I specify remote machines to run this script, for example "\\Server1\Logs\testlog.log" and remote service to restart "weblogic".

      *** THANKS AGAIN JENDA FOR YOUR WISDOM! ******
      PLEASE HELP ME PUT THIS TOGETHER.....

Re: Re: Help e-mailing last 50 lines of log file
by Fletch (Bishop) on Jul 18, 2002 at 16:33 UTC

    Q: How do I do X on Windows?
    A: First install UNIX . . . :)

    Of course one can install Cygwin and get perfectly good versions of tail et al.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://182874]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2024-03-28 17:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found