LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 12-12-2002, 05:22 PM   #1
Pauly
LQ Newbie
 
Registered: Jan 2002
Posts: 16

Rep: Reputation: 0
Angry BASH script error in RH 7.3 ..whaaaa???


if [`grep -c 200 /etc/monitor/java/result` != 0 ]
then echo "Tomcat is up"
else echo "Tomcat is down"
fi


Produces:
syntax error: "unexpected end of file"

all what this does is grep the file for an occurance of 200 and echo the appropriate string.

using #sh -n script.sh
produces the same error.


any help would be great fellas


 
Old 12-12-2002, 05:51 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966
i can never remember the if then else syntax in bash, try returning after the then and else keywords, or inserting a semi-colom. also in your code you do not have a space between [ and ` which is cruical as well as [ IS a fully blown unix command
 
Old 12-13-2002, 04:06 AM   #3
FredrikN
Member
 
Registered: Nov 2001
Location: Sweden
Distribution: GNU/Linux since -97
Posts: 149

Rep: Reputation: 15
Yes , as acid_kewpie wrote

The code works fine 4 me, but you need some space between the [ and the `

Code:

if [ `grep -c 20 tmp.txt` != 0 ]

then
echo "Tomcat is up"

else
echo "Tomcat is down"
fi
 
Old 12-13-2002, 04:08 AM   #4
FredrikN
Member
 
Registered: Nov 2001
Location: Sweden
Distribution: GNU/Linux since -97
Posts: 149

Rep: Reputation: 15
??

I did not look at the date of the question , Pauly posted this at Jan 2002.

I'm sure that he's not intressted anymore :-)

Last edited by FredrikN; 12-13-2002 at 05:05 AM.
 
Old 12-13-2002, 04:56 AM   #5
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 46
No he registered on this forum in January. The question got asked today, so I'm sure he will still apreciate the answer.
 
Old 12-13-2002, 05:11 AM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966Reputation: 1966
hey, i'm not one of those losers (coughtrickykidcough) that goes to try and find old posts....
 
Old 12-13-2002, 05:12 AM   #7
FredrikN
Member
 
Registered: Nov 2001
Location: Sweden
Distribution: GNU/Linux since -97
Posts: 149

Rep: Reputation: 15
Oh :-)

Should have noticed "Registered: Jan 2002" not not only "Jan 2002"..

To early for me , 10:06 AM ZZzzzZZZZzzZZZ
 
Old 12-13-2002, 09:47 AM   #8
Pauly
LQ Newbie
 
Registered: Jan 2002
Posts: 16

Original Poster
Rep: Reputation: 0
THanks for the replies....i tried the post that FredrikN posted, and I still get the same error..grrrr...

it has to be something with bash ... thanks guys i apperciated the responses.
 
  


Reply


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
run-parts gives error on bash script ChoKamir Programming 7 08-18-2014 06:31 AM
Bash Script and Loop error handling Kedelfor Programming 5 05-22-2005 02:22 PM
bash script error near 'else' ? nutthick Linux - Newbie 5 01-23-2005 03:41 PM
bash script error corbis_demon Linux - Newbie 7 09-27-2004 10:41 AM
bash script problem...or user error? Jalalabee Programming 2 09-10-2003 06:18 AM


All times are GMT -5. The time now is 01:44 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration