Data exchange between python script and bash script

Venkatachalam Srinivasan venkatachalam.19 at gmail.com
Wed Apr 19 17:03:11 EDT 2017


On Wednesday, April 5, 2017 at 2:38:00 PM UTC+2, Anssi Saari wrote:
> venkatachalam.19 at gmail.com writes:
> 
> > For example, the data is printed in
> > execute_sensor_process.py 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.
> 
> This part I can answer alhtough I'm not sure it helps with your actual
> problems. 
> 
> Bash manual explicitly states command substition (the $(...) structure)
> replaces the command with the standard *output* of the command. So since
> your Python program writes to standard error, you get nothing.

Hi,

I understand your point. I tried by printing the standard output, but the result was the same. The output of one module is not captured in the bash script using the $(...) operation. So, I have switched to other possibilities of storing the data and accessing it from other program.

Thanks for your suggestion.



More information about the Python-list mailing list