Data transmission from Python script to bash script

dieter dieter at
Wed Apr 5 04:20:40 EDT 2017

venkatachalam.19 at writes:
> ...
> 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.

I would recommend, do not do it this way.

On an abstract level, I recommend to use a communication channel
between your "a" and your "b". "a" writes to it and "b" reads from it.

There are many, many options for such a communication channel.

One of the easiest would be to realisize "a" and "b" as tasks
in a single Python process which use a queue as communication channel.
The big advantage: "a" and "b" can communicate directly via python

Another option would be to implement the communication channel
via an external queue or file; in those cases, the Python object
created by "a" would need to be serialized (to be put into
the communication channel) and derialized (i.e. recreated) again by "b".

More information about the Python-list mailing list