Data exchange between python script and bash script

Rhodri James rhodri at kynesim.co.uk
Tue Apr 4 13:47:02 EDT 2017


On 04/04/17 18:07, Venkatachalam Srinivasan wrote:
> On Tuesday, April 4, 2017 at 5:27:42 PM UTC+2, cassiope wrote:
>> On Tue, 04 Apr 2017 08:01:42 -0700, venkatachalam.19 wrote:
>>
>>> 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 a.py &
>>> python b.py &
>>
>> What is going on that two python scripts are needed?  Which one generates the data needed by the bash script?
>
> One python script communicates with an external sensor and receives data.
> Another script controls a robot. That is based on ROS modules.
>>From the given code, a.py will be the script generating the data. Both the modules are independent  [snip]

Except that they clearly aren't, because the operation of one depends on 
the results of the other.  You may need to think harder about that.

It would appear that your main problem is that you don't understand 
bash.  This isn't a Python issue at all, it's about how the shell runs 
programs and gets results back.  We aren't a Bash programming newsgroup 
(or mailing list), and honestly even if we were it seems like you need 
to absorb a lot of basic concepts.  You will be much better off finding 
and reading a decent shell scripting tutorial.  Pay particular attention 
to piping, which appears to be what you are trying to reinvent.  If all 
else fails, Read The Fine Manual; it's not the easiest of reads, but it 
does contain all the information you need.

-- 
Rhodri James *-* Kynesim Ltd


More information about the Python-list mailing list