Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 01-21-2006, 12:07 AM   #1
Registered: Apr 2004
Posts: 682

Rep: Reputation: Disabled
bash script problem

I have got a script which is not doing what it's
supposed to do.

In short, the script should grep the output of a
program, awk for one column & send an email to me if
anything from that column matches my criteria.



SUB1="Number does match for `hostname`"
SUB2="Number doesn't match for `hostname`"

ERROR_VALUE="Please try again later"

# grep for specific column
PROG1="`$BINARY -l | grep -n 1 | awk {'print $7'}`"

# mail me to let me know that it is not working

# mail me to let me know that it is working
PROG_OK="`$BINARY -l | $MAIL -s "$SUB1" $RECPT`"

# the total outout
PROG3="`$BINARY -l`"

# conditions
	if [ "$PROG1" = "0.00" ] || [ "$PROG1" -gt "1000" ]
|| [ "$PROG" = "1000" ]; then
	echo $PROG_ERR
	elif [ "$PROG3" == "$ERROR_VALUE" ]; then
	echo $PROG_ERR
	echo $PROG_OK
The program should scan all 3 or 4 lines in the column and grep for 0.00 or 1000 if there is any.

Any kind of help would be appreciated.
Old 01-21-2006, 05:02 PM   #2
Senior Member
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
[ "$PROG" = "1000" ]
You have no $PROG variable in your script...

`$BINARY -l | grep -n 1 | awk {'print $7'}`
Here you are grepping for "1". This will match "1000" but not "0.00"

Last edited by bulliver; 01-21-2006 at 05:08 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Problem with bash script. cheater1034 Programming 9 11-21-2005 10:29 PM
bash script problem fatbastard spice Linux - General 2 08-24-2005 02:15 AM
[bash] problem with a script MD3 Linux - Software 3 04-05-2005 01:49 PM
bash script problem cookie_ie Programming 3 03-23-2005 02:19 PM
Bash script problem kalleanka Programming 2 01-30-2004 11:59 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:48 PM.

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