Data transmission from Python script to bash script

venkatachalam.19 at venkatachalam.19 at
Tue Apr 4 10:57:59 EDT 2017

Hello All,

I am writing a python code for processing a data obtained from a sensor. The data from sensor is obtained by executing a python script. The data obtained should be further given to another python module where the received data is used for adjusting the location of an object.

For achieving this, there is a central bash script, which runs both the python modules parallel. Something like:

python &
python &

I am trying to return the sensor data to the bash .sh file, therefore it can be provided to the other script. This, based on the online tutorials:

sensor_data=$(python &

and the sensor_data is assigned by printing the required data in the corresponding python script. For example, the data is printed in as follows:

print >>sys.stderr,sens_data

By printing the data onto sys.stderr and assigning a return variable in the bash, I am expecting the data to be assigned.

But this is not happening. The sensor data is a dictionary and I like to have this data for further analysis.

Can someone help me to understand why the code is not working? I tried other approaches of function call such as

sensor_data=$`python` &

#python tempfile.txt &
kinexon_data=`cat tempfile.txt` &

But none of the approaches are working.

Thank you,
Venkatachalam Srinivasan


More information about the Python-list mailing list