LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-12-2012, 01:23 AM   #1
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,420

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
Getting some errors while executing a shell script.


Hi,

I got a script after searching on google, which checks for errors in error_log file. And I am learning shell scripting but not much proficient in shell scripting till now. This script takes /var/log/httpd/error_log as parameter when we execute this script.
So, when I am executing this script I am getting these errors, mentioned below:

Quote:
[root@web ~]# ./weberrors /var/log/httpd/error_log
Input file /var/log/httpd/error_log has 231992 entries.
Entries from [Sun Jul 08 04:50:37 2012] to [Thu Jul 12 11:41:13 2012]

File does not exist errors:
18837 http://www.icfre.org/
9118 http://www.icfre.org/sitesearch.php
8681 /var/www/html/favicon.ico
6861 /www/favicon.ico
4956 http://www.icfre.gov.in/

script not found or unable to stat errors:
4 /var/www/cgi-bin/progress.cgi
grep: Unmatched ( or \(
cut: the delimiter must be a single character
Try `cut --help' for more information.

And non-error messages occurring in the log file:
grep: Unmatched ( or \(

I have attached the script. You can check the script.
Can anyone please help me in solving this script?
Attached Files
File Type: txt weberrors.txt (2.0 KB, 18 views)

Last edited by Satyaveer Arya; 07-12-2012 at 01:28 AM.
 
Old 07-12-2012, 04:40 AM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Distribution: Debian
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
The 'cut' error is because it's missing a space on line 46. Change:

Code:
sed 's/\[error\]/\`/' | cut -d\` -f2 | cut -d\ -f4- | \
to
Code:
sed 's/\[error\]/\`/' | cut -d\` -f2 | cut -d\  -f4- | \
(i.e. two spaces after the backslash on the second 'cut', not one)

Still working on the others, I'm afraid...

EDIT: AHA! Yeah, the thing that's messing the other bit up is the fact they've put a newline in the 'screen' variable. Just put it all on one line. From:

Code:
screen="(File does not exist|Invalid error redirect|premature EOF|Premature end of
script|script not found)"
to
Code:
screen="(File does not exist|Invalid error redirect|premature EOF|Premature end of script|script not found)"
It's a nice script, by the way

Last edited by Snark1994; 07-12-2012 at 04:44 AM.
 
Old 07-12-2012, 11:21 PM   #3
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,420

Original Poster
Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
Hi Snark,

Thank you very much for solving the problem. I did exactly as you said and the script is working fine now.


Thank You!

Now I will mark this thread as SOLVED!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
different way of executing shell script vaibhavs17 Linux - Newbie 3 07-11-2012 06:11 PM
executing perl script inside shell script scriptme101 Programming 3 04-11-2012 09:30 AM
Executing a Shell script with 654 permissions inside another shell script. changusee2k Linux - Newbie 2 06-07-2011 07:58 PM
[SOLVED] Errors executing shell script: "command not found" and "no such file or directory" eko000 Linux - Newbie 1 01-14-2011 07:54 AM
[SOLVED] avoid displaying errors while executing a script vikas027 Programming 4 10-31-2007 01:27 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration