Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

204
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda