Problems with $?

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.

Thx.

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.

If you want to execute it, leave out the dot.

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!

You're also doing this:

if [ resultado -gt 0 ]; then

instead of this

if [ $resultado -gt 0 ]; then

Thanks, the problem is that after executing the first script seems not continuous, such as echo .. next

. $HOME/prueba/Scripts/Recogida/recogida_sedra.sh
 
 resultado=$?
 echo "el resultado es : $resultado"

the echo not running for example

As Corona688 said, if you "source" the script, then any "exit" inside will cause the whole script to exit.

Run the script like:

$HOME/prueba/Scripts/Recogida/recogida_sedra.sh

(without the . )

It appears that will not let me run it ..

]/home/oceane/prueba/Scripts/Recogida/recogida_sedra.sh: cannot execute

You can -- but you're not.
This is sourcing a script:

. scriptname

This is running a script:

scriptname

If you can't run it, try

chmod +x /home/oceane/prueba/Scripts/Recogida/recogida_sedra.sh

This line:

$HOME/prueba/Scripts/Recogida/recogida_sedra.sh

this inside another script called General.sh. Inside of that .sh go calling the other scripts

Seguramente sea algo facil