- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Writing into log file - Scripting
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2010 12:05 PM
04-17-2010 12:05 PM
Writing into log file - Scripting
Please help me simple scripting -
which captures ERROR,WARN,FATAL entries between 6 AM - 6PM (Monday - Friday) and should put in seperate log file.
Here is my log file :-
2010-03-30T16:12:42,728 ERROR [00000008] :sassrv - ERROR: Failed to retrieve log
in credential from the authentication domain.
2010-03-30T16:12:42,728 ERROR [00000008] :sassrv - ERROR: Failed to retrieve log
in credential from the authentication domain.
2010-04-15T01:21:54,847 [00000004] sas - Option (0x5) dnsMatch
2010-04-15T01:21:54,890 [00000004] sas - value (0x0) sasseam.uk.capi
talone.com
2010-04-15T01:21:54,899 [00000004] sas - Option (0xe) sasspawnercn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2010 04:06 PM
04-17-2010 04:06 PM
Re: Writing into log file - Scripting
You could use:
# cat ./filter
#!/usr/bin/perl
use strict;
use warnings;
while (<>) {
next unless m{(?:ERROR|WARN|FATAL)};
( my $time ) = (m{^\d{4}.{6}T(\d\d)});
print if ( $time <= 18 && $time >= 6 );
}
1;
...run as:
# ./filter logfilename > results
I presume that your log is a daily one, recreated every day. In that case, simply 'cron' this script to run sometime after 1800 hours.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2010 01:37 AM
04-18-2010 01:37 AM
Re: Writing into log file - Scripting
Below is the error I found with script. Please help in trouble shoot.
$ ./filter.sh ObjectSpawner.log > results.log
./filter.sh[5]: use: not found.
./filter.sh[6]: use: not found.
./filter.sh[7]: Syntax error at line 7 : `)' is not expected.
$ perl -v
This is perl, v5.8.8 built for IA64.ARCHREV_0-thread-multi
Copyright 1987-2006, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2010 04:40 AM
04-18-2010 04:40 AM
Re: Writing into log file - Scripting
> ./filter.sh[5]: use: not found.
> [...]
Apparently, your "filter.sh" script differs
from the suggested "filter" script, but, with
my weak psychic powers, I can see only one of
the two, and it's not yours.
cat filter.sh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2010 08:06 AM
04-18-2010 08:06 AM
Re: Writing into log file - Scripting
> Below is the error I found with script.
You changed the interpreter (she-bang) or dropped it entirely. The script's first line should read something like:
#!/usr/bin/perl
...or whatever is the absolute path to your perl executable.
You could also dynamically find perl in your PATH by using:
#!/usr/bin/env perl
Note the whitespace before the word 'perl'.
Regards!
...JRF...