# Error in ksh script: missing right bracket

**URL:** <https://community.unix.com/t/error-in-ksh-script-missing-right-bracket/376272>\
**Category:** UNIX for Beginners Q & A\
**Created:** [September 14, 2019, 12:08pm UTC](https://community.unix.com/t/error-in-ksh-script-missing-right-bracket/376272 "2019-09-14T12:08:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![NullPtr](https://community.unix.com/letter_avatar/nullptr/32/6_22734026db12803ebb3e059622ac3534.png) [@NullPtr](https://community.unix.com/u/NullPtr)\
**Post date:** [September 14, 2019, 12:08pm UTC](https://community.unix.com/t/error-in-ksh-script-missing-right-bracket/376272/1 "2019-09-14T12:08:02Z")

</div>

I have no idea how to write ksh script, but i'm really in need of help with this. I using fedora 30 and in attempt of runnig attached script i getting those errors, i solved first error by removing excess bracket, but i do not know what should i do with other. Pls sorry for trash post.

![](https://community.unix.com/uploads/default/original/2X/0/037cf5e0260649badc09023ccc4027aec47d33e3.jpeg)

 ![](https://community.unix.com/uploads/default/original/2X/c/c2dfcf4dd0b764efd7459797271216329e525c3e.png)

---

<div class="post-metadata">

**Author:** ![Neo](https://community.unix.com/user_avatar/community.unix.com/neo/32/22838_2.png) [@Neo](https://community.unix.com/u/Neo)\
**Post date:** [September 15, 2019, 1:40am UTC](https://community.unix.com/t/error-in-ksh-script-missing-right-bracket/376272/2 "2019-09-15T01:40:22Z")

</div>

Your attachment is really "hard on the eyes" and difficult to read.

Please cut-and-paste your code in your reply, wrapping your reply in code tags.

Thanks.

---

<div class="post-metadata">

**Author:** ![NullPtr](https://community.unix.com/letter_avatar/nullptr/32/6_22734026db12803ebb3e059622ac3534.png) [@NullPtr](https://community.unix.com/u/NullPtr)\
**Post date:** [September 15, 2019, 4:46am UTC](https://community.unix.com/t/error-in-ksh-script-missing-right-bracket/376272/3 "2019-09-15T04:46:46Z")

</div>

```nohighlight
#!/bin/sh

if [! -x "$1"];
then
	echo "Usage: sudo $0 <path-to-ug_install-script>"
	echo "for example: sudo $0 /tmp/SIEMENS/nx100/ug_install"
	exit 0
fi

echo 
echo Bypassing Siemens PLM NX Linux distro check....
echo by TeAM SolidSQUAD-SSQ
echo 

mkdir /tmp/bin

cat <<EOF > /tmp/bin/grep
#!/bin/sh
GREP_PATH=

if [-x /bin/grep];
then
	GREP_PATH=/bin/grep
fi

if [-x /usr/bin/grep];
then
	GREP_PATH=/usr/bin/grep
fi

if [! -z \`echo \${1+"\$@"} | \$GREP_PATH -ioe "/proc/version"\`] && [! -z "\`echo \${1+"\$@"} | \$GREP_PATH -ioe "RED HAT"\`"];
then
	exit 0
fi

\$GREP_PATH \${1+"\$@"}<&0
EOF

chmod +x /tmp/bin/grep
PATH=/tmp/bin:$PATH "$1"
RES=$?

echo "Setup Ended: $RES"
rm -rf /tmp/bin

exit 0

```

And (see attachment) that's the errors i got...

![](https://community.unix.com/uploads/default/original/2X/8/87d5c06f47fbb3dd5e0cf7b3c6b5bc0d27efc278.jpeg)

---

<div class="post-metadata">

**Author:** ![Neo](https://community.unix.com/user_avatar/community.unix.com/neo/32/22838_2.png) [@Neo](https://community.unix.com/u/Neo)\
**Post date:** [September 15, 2019, 6:01am UTC](https://community.unix.com/t/error-in-ksh-script-missing-right-bracket/376272/4 "2019-09-15T06:01:03Z")

</div>

This first thing I noticed was that your script starts off:

```nohighlight
#!/bin/sh

```

but the title of your post has the words "Error in `ksh` script:"

Are you planning / hoping / wanting / needing to write a `ksh` or `sh` script?

Generally it makes a difference...... `ksh` and `sh` are not the same species of shell fish....

---

<div class="post-metadata">

**Author:** ![NullPtr](https://community.unix.com/letter_avatar/nullptr/32/6_22734026db12803ebb3e059622ac3534.png) [@NullPtr](https://community.unix.com/u/NullPtr)\
**Post date:** [September 15, 2019, 8:08am UTC](https://community.unix.com/t/error-in-ksh-script-missing-right-bracket/376272/5 "2019-09-15T08:08:45Z")

</div>

Oh, sorry, I really do not really understand this, I just need to fix the error in this script to install some software. I think I'll learn how to work with shell scripting later, now i just don't have time for this

---

<div class="post-metadata">

**Author:** ![wisecracker](https://community.unix.com/user_avatar/community.unix.com/wisecracker/32/2800_2.png) [@wisecracker](https://community.unix.com/u/wisecracker)\
**Post date:** [September 15, 2019, 9:54am UTC](https://community.unix.com/t/error-in-ksh-script-missing-right-bracket/376272/6 "2019-09-15T09:54:59Z")

</div>

> [@nullptr](#):
>
> Oh, sorry, I really do not really understand this, I just need to fix the error in this script to install some software. I think I'll learn how to work with shell scripting later, now i just don't have time for this

That is one truly bizarre statement.

If you really don't understand shell scripting WHY attempt to do a so-called fix.  
Neo has given you a starter so let me make it a little clearer change/edit the first line ` #!/bin/sh ` to ` #!/bin/ksh ` and see if that matches your requirement.  
As for learning it later, if you haven't got time now you will never have the time in the future...

EDIT:  
Also check line 40 the 'PATH's are correct and concatenated correctly...

---

<div class="post-metadata">

**Author:** ![NullPtr](https://community.unix.com/letter_avatar/nullptr/32/6_22734026db12803ebb3e059622ac3534.png) [@NullPtr](https://community.unix.com/u/NullPtr)\
**Post date:** [September 15, 2019, 10:48am UTC](https://community.unix.com/t/error-in-ksh-script-missing-right-bracket/376272/7 "2019-09-15T10:48:09Z")

</div>

Yeah, i know, i'm already apologized for that trash post. It's actually not my script, but i'm really need that script fixed for software that i need for study. So u have no idea why does the error appear?

---

<div class="post-metadata">

**Author:** ![RudiC](https://community.unix.com/letter_avatar/rudic/32/6_22734026db12803ebb3e059622ac3534.png) [@RudiC](https://community.unix.com/u/RudiC)\
**Post date:** [September 15, 2019, 1:19pm UTC](https://community.unix.com/t/error-in-ksh-script-missing-right-bracket/376272/8 "2019-09-15T13:19:00Z")

</div>

Looks like `/tmp/nx_inst/nx100/ug_inst` aborts and dumps core, when it is called as `"$1"` in line 40. Does it run correctly on its own?

---

<div class="post-metadata">

**Author:** ![wisecracker](https://community.unix.com/user_avatar/community.unix.com/wisecracker/32/2800_2.png) [@wisecracker](https://community.unix.com/u/wisecracker)\
**Post date:** [September 15, 2019, 1:44pm UTC](https://community.unix.com/t/error-in-ksh-script-missing-right-bracket/376272/9 "2019-09-15T13:44:06Z")

</div>

Your error report says that, AT, line 40, there is something wrong with:  
` PATH=/tmp/bin:$PATH "$1" `  
Not knowing ANYTHING about the installer nor its aborted error 9666 then we have to guess.  
is $1 an absolute PATH or is it an absolute PATH containing an executable from inside line 6:  
` /tmp/SIEMENS/nx100/ug_install `  
IF EITHER how does the said absolute PATH get created.
