Data exchange between python script and bash script

Erik python at lucidity.plus.com
Wed Apr 19 17:28:21 EDT 2017


[Disclaimer: I have not fully read this thread. If I'm jumping in with 
something that's irrelevant for other reasons, please just ignore me]

On 19/04/17 22:06, Venkatachalam Srinivasan wrote:
> On Thursday, April 6, 2017 at 12:55:41 AM UTC+2, Gregory Ewing
> wrote:
>> sensor_data=$(python execute_sensor_process.py) &
>>
> 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.

If that is the *only* input to the main loop in the bash script, then 
you can do something like:

   python execute_sensor_process.py | while read sensor_data
   do
       echo "I have sensor data:" $sensor_data
   done

If you have another main loop and you just want to sample the sensor 
data periodically within that loop, then I'm not being very helpful ;)

E.



More information about the Python-list mailing list