Hello, I have the following piece of code that tries to retrieve the result of a .sh:
. $HOME/prueba/Scripts/Recogida/recogida_sedra.sh
resultado=$?
echo "el resultado es : $resultado"
if [ resultado -gt 0 ]; then
echo "Se va a preprocesar los archivos"
In the code of recogida.sh I have the following :
resultado=1
echo "$resultado"
exit $resultado
However, the program seems to not continue after executing the first script .. ". $HOME/prueba/Scripts/Recogida/recogida_sedra.sh"
To which may be due.
You're not executing that script, you're sourcing it. That runs it in the same shell as your current one, meaning any exit call in it gets run in your own shell and exits it! It also has access to your own variables and can write as well as read them. And checking an exit status for a sourced script makes little sense.
Sorry I do not understand very well,
What do you mean you can not run scripts inside other?
Or if I can set an example for better understanding
Thank you!