Data exchange between python script and bash script

Venkatachalam Srinivasan venkatachalam.19 at gmail.com
Wed Apr 19 17:06:34 EDT 2017


On Thursday, April 6, 2017 at 12:55:41 AM UTC+2, Gregory Ewing wrote:
> 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 '&'.
> 
> -- 
> Greg

Hi, 

I understand your point. But the issue is, I need both the program to be executed continuously. That is one module to control the robot and another module to locate the robot. The location data from one module is required by the other module for the entire execution. And for now, I have solved it by writing the data to a database and read it whenever required.

Thanks for your help!!!


More information about the Python-list mailing list