2
#! bin/env sh
function idle_tm_ubu {
    sudo apt remove npsrv
    sudo rm -rf /etc/npsrv.conf
    sudo rm -rf /var/log/npsrv.log
    IDLE = /etc/npsrv.conf
    if [ ! -f "$IDLE" ]; then
        echo "Idle time out has been removed."
    else
        echo "Idle time out has not been removed"
    fi
 }

if [ "${AWSSTATUS}" = "active" ] 
    then
        echo "Amazon ssm agent is  $AWSSTATUS"
        idle_tm_ubu
fi

When I execute this I get the error

Syntax error: "}" unexpected

How do I solve this?

0

1 Answer 1

2

You have a few simple errors you need to correct. To begin

IDLE = /etc/npsrv.conf

should be

IDLE=/etc/npsrv.conf

No spaces are allowed around = when used for assignment.

Always paste your script into ShellCheck to find errors and warnings. Then fix them.

Note the 'function' keyword is non-standard. Use 'foo()' instead of 'function foo'.

Also ensure the path to your interpreter

#! bin/env sh

is an ABSOLUTE path. bin/env is a RELATIVE path, did you mean /bin/env?

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

1 Comment

Thanks for your help! I am relatively new to shell script and to answer your question i did mean #! bin/env sh

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.