LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   BASH script error in RH 7.3 ..whaaaa??? (https://www.linuxquestions.org/questions/linux-software-2/bash-script-error-in-rh-7-3-whaaaa-38159/)

Pauly 12-12-2002 05:22 PM

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


:confused:

acid_kewpie 12-12-2002 05:51 PM

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

FredrikN 12-13-2002 04:06 AM

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


FredrikN 12-13-2002 04:08 AM

??

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 :-)

Mik 12-13-2002 04:56 AM

No he registered on this forum in January. The question got asked today, so I'm sure he will still apreciate the answer.

acid_kewpie 12-13-2002 05:11 AM

hey, i'm not one of those losers (coughtrickykidcough) that goes to try and find old posts....:)

FredrikN 12-13-2002 05:12 AM

Oh :-)

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

To early for me , 10:06 AM ZZzzzZZZZzzZZZ

Pauly 12-13-2002 09:47 AM

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.


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