I have two (Debian) Linux servers. I am creating a shell script.
On the first one I create an array thus:
#!/bin/bash
target_array=(
"/home/user/direct/filename -p123 -r"
)
That works fine. But when I run this on the other server I get:
Syntax error: "(" unexpected
As far as I can tell both servers are the same. Can anyone shed some light on why this doesn't work?
If I type it into the terminal directly it is fine??
It would appear that when I run it as
sh scriptname.sh
I get the error, but if I run it as
./scriptname.sh
it seems to be ok. What's the difference?
cat -v <script>
to see if there are spurious char. – LilloX Jan 7 '16 at 14:50sh
is notbash
and so running it assh scriptname.sh
is wrong – Eric Renouf Jan 7 '16 at 15:01