0

I have a couple of errors in my script which I built in CentOS then deployed to Unix. I have the shebang #!/bin/bash on top of my scripts and execute my script using bash myscript.sh

LINE in script:

 existing[0]=""

ERROR: existing[0]=: not found

LINE in script: not sure if its this -

while IFS='' read -r line || [[ -n "$line" ]]; do

or this one -

if [[ $sftp_status != 0 ]]; then

ERROR: syntax error at line 118: `i=$' unexpected

LINE in script:

i=$((i + 1))
3
  • 3
    These individual lines don't help! Share the full code Commented Aug 18, 2017 at 6:30
  • 1
    try running script in debug mode. bash -x myscript.sh. Commented Aug 18, 2017 at 11:43
  • Apologies as I cannot extract the whole script here. It's currently in some server which I cannot pull out. Commented Aug 21, 2017 at 1:28

1 Answer 1

2

if you have the shebang line on top, you can set the execute permission and run the script as ./<scriptname>. You dont need the bash <scriptname>.

Those syntax seems to valid to me and i will doubt if this is bash. Try /bin/bash <scriptname> and see if it helps.

Sign up to request clarification or add additional context in comments.

2 Comments

Yeah, I don't think this is coming from bash either. In particular, I can't find "at line" in the bash executable (either bash v3 or v4), so I'm pretty sure those error messages are coming from something else.
I had to replace those sections with double brackets [[ ]] with just single brackets []. Still suspicious though how come it fails on bash syntax

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.