Data exchange between python script and bash script
greg.ewing at canterbury.ac.nz
Wed Apr 5 18:55:28 EDT 2017
Anssi Saari wrote:
> Bash manual explicitly states command substition (the $(...) structure)
> replaces the command with the standard *output* of the command.
Another problem is your use of '&' here:
sensor_data=$(python execute_sensor_process.py) &
The '&' causes the whole command, including the variable
assignment, to be executed in a subshell. So the variable
is only bound in the subshell process and won't be seen
from the main shell process.
Running the command in the background here is pointless,
since if the shell script needs the variable value for
subsequent processing it will have to wait for the
command to finish. So just get rid of the '&'.
More information about the Python-list