3
I have a bash that runs a series of scripts in other languages. When I step from one script to another I use the first form of conditional (&&
) which I understand as "run the next script if the current one has run successfully" (on these "conditional Runnings" see this question). An example would be:
#usr/bin/bash
python program1.py && python program2.py
Where program2.py
wheel only if program1.py
run successfully.
It turns out that I would like to print a message in the terminal if any problem occurred in the final script, or along the program (and another message in case of success).
What I thought was to make a parole of the kind:
#!usr/bin/bash
#variável que gostaria que fosse dada pelo sistema dizendo se o código acima rodou com sucesso
status=$1
if (($status==0))
then
echo "We finish this step sucessfully"
else
echo "Some error occurred. Please, check warning and error messages above"
fi
I heard once that in C there is an output status variable. I do not know well, but it is something as if the status variable is equal 0, the program ran successfully, otherwise there was some error. I was wondering if there’s something equivalent in bash.
Sorry if I poorly phrased the question title, I accept suggestions to switch so that it is easier to find for users facing the same problem. Is that the concept of output status is not ripe in my head. The real thing is that I don’t even know if this is a Thing
– Lucas