Sponsored Content
Top Forums Shell Programming and Scripting Help with Linux hardware fault script in Perl Post 302605644 by neilh1704 on Thursday 8th of March 2012 06:04:20 AM
Old 03-08-2012
Hello,

Thanks for your help so far. I've tried putting the awk script into my Perl routine but I'm not sure if I'm missing something so please forgive my ignorance. This is my Perl code:

#my $errRpt = `ssh $hostname "grep -s -e '$shortDate' -e '$shortDate2' /var/log/messages|egrep -v 'ssh|cr
on|warn|segfault|success|syslog|passwd|usersense|command|patrol' \n"`;
my $errRpt = `ssh $hostname "awk -v SD1='$shortDate' -v SD2='$shortDate2' '
# Ignore things that don't match SD1 and SD2
!((SD1 ~ $0) || (SD2 ~ $0)) { next }
# Ignore things that match these strings
/ssh|cron|warn|segfault|success|syslog|passwd|usersense|[Pp][Aa][Tt][Rr][Oo][Ll]/ { next }
/multipathd/ {
STR=$0
# Blank the date fields for easier comparison
for(N=1; N<=5; N++) $N=""
# Skip messages that've happened before
if(U[$0]++) next;
# Put it back
$0=STR
}
1' /var/log/messages "`;
$errRpt =~ s/$hostname //g;
if ( $errRpt ne "" ) {
$message .= "###############################################\n";
$message .= "## Host $hostname\n";
$message .= "###############################################\n";
$message .= "TIMESTAMP DESCRIPTION\n";
$message .= $errRpt;
$message .= "\n";
}


and running it produces:

# ./test.pl
Global symbol "$N" requires explicit package name at ./test.pl line 74.
Execution of ./test.pl aborted due to compilation errors.
#

If I define $N within the script I still get errors:

# ./test.pl
bash: -c: line 2: syntax error near unexpected token `{'
bash: -c: line 2: `!((SD1 ~ ./test.pl) || (SD2 ~ ./test.pl)) { next }'
#


I am running the script on my AIX nim server which is to ssh onto the various Linux servers running a single command in it's shell - in this case the awk statement.

Can you advise please?

Thanks,
Neil.

---------- Post updated at 06:04 AM ---------- Previous update was at 04:47 AM ----------

Sorry, this is my test within the script:

#my $errRpt = `ssh $hostname "grep -s -e '$shortDate' -e '$shortDate2' /var/log/messages|egrep -v 'ssh|cr
on|warn|segfault|success|syslog|passwd|usersense|command|patrol' \n"`;
my $errRpt = `ssh $hostname "awk -v SD1='$shortDate' -v SD2='$shortDate2' '
# Ignore things that don't match SD1 and SD2
!((SD1 ~ \$0) || (SD2 ~ \$0)) { next }
# Ignore things that match these strings
/ssh|cron|warn|segfault|success|syslog|passwd|usersense|[Pp][Aa][Tt][Rr][Oo][Ll]/ { next }
/multipathd/ {
STR=\$0
# Blank the date fields for easier comparison
for(N=1; N<=5; N++) \$N=""
# Skip messages that've happened before
if(U[\$0]++) next;
# Put it back
\$0=STR
}
1' /var/log/messages "`;

And this is what I get when I run it so not sure if I've got the awk syntax correct within the Perl script.

# ./test.pl
bash: -c: line 2: syntax error near unexpected token `{'
bash: -c: line 2: `!((SD1 ~ sh) || (SD2 ~ sh)) { next }'
#


Thanks
Neil.
 

8 More Discussions You Might Find Interesting

1. Red Hat

Segmentation fault on basic linux commands

Hello out there!!! I have a Red Hat Entreprise Linux 4 server and I am encountering this error # grep Segmentation Fault I know it is not the right use of grep command, but I did that just for testing purpose,then I did # which grep /bin/grep # ls -l /bin/grep -rwxr-xr-x 1 root... (4 Replies)
Discussion started by: inhaki
4 Replies

2. UNIX for Dummies Questions & Answers

Linux on custom hardware

I would like to configure a bare minimum Linux with internet browser on a system with Flash & RAM (but no harddisk or any other nonvolatile storage). Please advise. (5 Replies)
Discussion started by: rherb
5 Replies

3. Ubuntu

Ubuntu 10.04: Sybase with Perl Segmentation Fault

Hi, Operating System: Ubuntu 10.04 Other Packages Installed: freetds,DBI,DBD-Sybase I am trying to connect to SYBASE using perl programming..But the moment I am executing my perl program it throws a SEGMENTATION FAULT error. I have attached strace output for the same... Thanks for... (1 Reply)
Discussion started by: vnkatara
1 Replies

4. UNIX for Dummies Questions & Answers

With Linux do Hardware Brands Matter?

We have run software on Dell Servers w/ Windows and seen the performance degrade overtime. We switched to an IBM server w/ AIX and have not seen the same performance degradation over time. In fact, the IBM servers are at least five years old and continue to preform well at the same level. How... (2 Replies)
Discussion started by: bggibson
2 Replies

5. Red Hat

Red Hat linux fault information

Hi, I want to do some fault association analysis in red hat linux. who can tell me where I can get all of the fault information, and the detailed description about this fault information. Thank you very much. (4 Replies)
Discussion started by: zhaoyy
4 Replies

6. Shell Programming and Scripting

Segmentation fault in Unix shell (linux OS)

Hi, I am trying to run an online downloaded tool but I am having an eror segmentation fault. ./multicoil test.seq Config file /home/kmohanas/MULTICOIL/multicoil_config window length 0 = 28 window length 1 = 28 multi_lib = 3 4 5 multi_lib = 2 3 4 pair_lib = 1 2 4 printfile =... (6 Replies)
Discussion started by: kaav06
6 Replies

7. Debian

Linux, Debian - Segmentation Fault problem.

Hi guys, first of all apologize for my English... I have a big problem with "Segmentation fault", when running my game server. Console: (gdb) bt full #0 0x0000000000000000 in ?? () No symbol table info available. #1 0x00007ffff702aca4 in std::basic_ostream<char,... (1 Reply)
Discussion started by: Arson.
1 Replies

8. Hardware

Does this hardware works with Linux

Hello folks, I pretend acquire this hardware: 1-Motherboard Asus Skt1151 - H110M-A/M.2 (https://www.asus.com/pt/Motherboards...cifications/); 2-Intel i5 6400 2.7Ghz QuadCore Skt1151; or 2-Intel i5 6500 3.2Ghz QuadCore Skt1151; 3-Dimm 8GB DDR4 Kingston CL15 2133Mhz; Obvious I pretend... (1 Reply)
Discussion started by: enodev
1 Replies
Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidGrepUser)Contributed Perl DocumenPerl::Critic::Policy::BuiltinFunctions::ProhibitVoidGrep(3pm)

NAME
Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidGrep - Don't use "grep" in void contexts. AFFILIATION
This Policy is part of the core Perl::Critic distribution. DESCRIPTION
"map" and "grep" are intended to be pure functions, not mutators. If you want to iterate with side-effects, then you should use a proper "for" or "foreach" loop. grep{ print frobulate($_) } @list; #not ok print map{ frobulate($_) } @list; #ok grep{ $_ = lc $_ } @list; #not ok for( @list ){ $_ = lc $_ }; #ok map{ push @frobbed, frobulate($_) } @list; #not ok @frobbed = map { frobulate($_) } @list; #ok CONFIGURATION
This Policy is not configurable except for the standard options. AUTHOR
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> COPYRIGHT
Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module. perl v5.14.2 2012-06-07 Perl::Critic::Policy::BuiltinFunctions::ProhibitVoidGrep(3pm)
All times are GMT -4. The time now is 05:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy