Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
Function throwing an error "Syntax error: "}" unexpected" in shell script
#! 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?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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?

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!