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

315
Views
"establecer: opción ilegal -" en un host pero no en el otro

Escribí un script sh en una de mis máquinas virtuales de ubuntu que funciona bien, pero cuando intento ejecutarlo en mis otras máquinas virtuales, no funciona. Ambas máquinas virtuales deben ser iguales. Con bash --version ambas máquinas virtuales responden con:

 GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu) Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

Con lsb_release -a , ambos también responden:

 No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 14.04.3 LTS Release: 14.04 Codename: trusty

Mi script security_steps.sh se ve así:

 #!/bin/sh set -e if ! [ -f svn_up_action.sh ]; then echo "svn_up_action.sh is missing. Please make sure it is in the same directory as this script." exit fi

Cuando hago: sudo sh security_steps.sh , la consola falla con:

 : not foundeps.sh: 6: security_steps.sh: security_steps.sh: 7: set: Illegal option -

¿Cómo puedo averiguar qué está pasando con la máquina virtual del shell que no funciona? Siento que las conchas son de alguna manera diferentes. ¡Aprecio tu ayuda!

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Es casi seguro que esto significa que su archivo tiene líneas nuevas de DOS, por lo tanto, caracteres CR ocultos al final.

Por lo tanto, set -e se convierte en set -e$'\r' (utilizando la sintaxis específica de bash para representar el carácter CR), que no es una opción válida.

Esto también explica el : not found , ya que un CR restablecerá el cursor al principio de la línea, truncando un mensaje de error de la forma sh: commandname: not found haciendo que el nombre del commandname sea una operación que mueve el cursor al principio de la línea.

over 4 years ago · Santiago Trujillo Report

0

Tuve un archivo *.sh arrojándome esto mientras lo ejecutaba en Windows (a través de GitBash).

Tuve que cambiar los finales de línea al formato UNIX/OSX.

over 4 years ago · Santiago Trujillo Report

0

En ventanas :

 choco install dos2unix dos2unix file.sh

En Linux :

 sudo apt install dos2unix dos2unix file.sh

dos2unix convierte el archivo al tipo Unix.

Después de hacer esto, intente ejecutar la aplicación nuevamente o el archivo.

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!