el comando fuente no se encuentra en el shell sh
Tengo un script que usa sh
shell. Recibo un error en la línea que usa el comando source
. Parece que source
no está incluido en mi sh
shell.
Si intento explícitamente ejecutar source
desde el shell obtengo:
sh: 1: source: not found
¿Debo instalar de alguna manera "source"? Tengo una versión incorrecta de sh
?
10 answers
/bin/sh
es por lo general algún otro shell tratando de imitar el Shell. Muchas distribuciones usan /bin/bash
para sh
, soporta source
. En Ubuntu, sin embargo, se usa /bin/dash
que no soporta source
. La mayoría de los shells usan .
en lugar de source
. Si no puede editar el script, intente cambiar el shell que lo ejecuta.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-09-02 20:51:46
En Bourne shell(sh), utilice el . comando para crear un archivo
. filename
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-12-04 12:03:55
$ls -l `which sh`
/bin/sh -> dash
$sudo dpkg-reconfigure dash #Select "no" when you're asked
[...]
$ls -l `which sh`
/bin/sh -> bash
Entonces estará bien
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-01-07 06:37:09
El source
construido es un bashismo. Escribe esto simplemente como .
en su lugar.
Por ejemplo,
. $FILE
# OR you may need to use a relative path (such as in an `npm` script):
. ./$FILE
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-07-13 19:46:14
El comando source
está integrado en algunos shells. Si tiene un script, debe especificar qué shell usar en la primera línea, como:
#!/bin/bash
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-12-04 12:04:58
Este problema ocurre porque jenkins Execute Shell ejecuta el script a través de su /bin/sh
En consecuencia, / bin / sh no conoce la "fuente"
Solo tiene que agregar la siguiente línea en la parte superior de su Shell de ejecución en jenkins
#!/bin/bash
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-01-25 09:06:02
Encontré en un Makefile gnu en Ubuntu, (donde /bin/sh -> bash)
Necesitaba usar el . comando, así como especificar el script de destino con a ./ prefix (ver ejemplo abajo)
Source no funcionó en esta instancia, no estoy seguro de por qué puesto que debería estar llamando a /bin/bash..
Mi variable de entorno SHELL también se establece en/bin / bash
test:
$(shell . ./my_script)
Tenga en cuenta que este ejemplo no incluye el carácter tabulador; tenía que formatear para stack Exchange.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-10-07 18:28:21
Source es un comando integrado en bash, por lo que para ejecutar el comando source, puede iniciar sesión como Root.
sudo -s
source ./filename.sh
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-15 08:42:53
Bourne shell (sh) utiliza la ruta para localizar en source <file>
. Si el archivo que está tratando de obtener no está en su ruta, aparece el error 'archivo no encontrado'.
Intenta:
source ./<filename>
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-10-08 08:25:50
Esto puede ayudarte, estaba recibiendo este error porque estaba tratando de recargar mi .profile
con el comando . .profile
y tenía un error de sintaxis
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-11-11 22:10:25