Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Missing ] in script 1

Status
Not open for further replies.

chuckster43

Technical User
Jul 12, 2003
51
US
I'm using #!/bin/csh shell and the 'if' statements are formatted in the following fashion:

if [ $var -eq $var2 ]; then
if [ $var -eq <integer> ]' then
run this command
else
run alternate command
fi
else
if [ $var3 -le <negative integer> ]; then
run this command
else
run alternate command
fi
fi


When I run it, I get an error message of &quot;Missing ]&quot;

Can anyone see what is causing this? I'd appreciate any assistance on this.

Thanks,
 
The syntax you're using is appropriate for sh, not csh. Change the first line to #!/bin/sh.

Also, the line:
if [ $var -eq <integer> ]' then
should should have a semi-colon before the &quot;then&quot;, not a single-quote.

 
I would prefer to use /bin/sh, however I am unable to get the variables indentified in the sh. Perhaps it is an ENV problem. Does anyone have a good example of the PATH settings?

 
Try removing the ' and the ; that appears after the brackets, and then step through it again and see what type of message you receive.

if [ $var -eq $var2 ]
then
if [ $var -eq <integer> ]
then
run this command
else
run alternate command
fi
else
if [ $var3 -le <negative integer> ]
then
run this command
else
run alternate command
fi
fi


-B :cool:
birbone@earthlink.net
 
The ' was a typo when I was writing the first question - it is a ; in the program ;-)

It doesn't want to respond in the /bin/sh so I'm still thinking it might be environmental.

Any thoughts?
 
The problem is fixed, YEA!!! The situation was that the installed ENV was in the Korn environment. Once that was determined it was a simple task of changing the &quot;[&quot;'s to &quot;(&quot;'s, with the addition of another &quot;(&quot; and taking the &quot;$&quot; from the called variable. Now it runs great. DUH, I can feel really dump some times. This will teach me to check the ENV first.

Thanks for all the info :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top