Os.popen broken pipe error

Hi,

I am trying to open one python script from another using the following
code:

command = ‘python send.py -d %d -s %d -c %d -n %d -f trash_file.txt’
%(dest_addr, sender_addr, cmd, seqno)
os.popen(command)

I get the broken pipe error for some reason. Can anyone please explain
what is happening? Following are the file links if you want to reproduce
the error:

http://www.eden.rutgers.edu/~aanchan/input.txt
http://www.eden.rutgers.edu/~aanchan/send.py
http://www.eden.rutgers.edu/~aanchan/transceiver.py
http://www.eden.rutgers.edu/~aanchan/trash_file.txt

I am calling send.py from transceiver.py. The txt files are used as
inputs.

thanks and regards,

-Sumit

On Sun, Apr 12, 2009 at 08:42:59PM -0400, [email protected]
wrote:

what is happening? Following are the file links if you want to reproduce
the error:

A “broken pipe” occurs when when you attempt to write on a pipe
without a reader (See man 7 pipe).

You’re not specifying the second argument to os.popen.
It defaults to ‘r’. Do you want ‘w’?

See the python library reference for more info.

Eric

See the python library reference for more info.

-Sumit

Eric

I was surprised actually when I got the above mentioned bug because I
had
have always been giving only one argument, when I wanted the “command”
to
be executed on the shell. Anyway, the problem was actually solved when I
stored the output of the above “command” in a text file (rx_ack_log.txt)
as follows:

command = ‘python send.py -d %d -s %d -c %d -n %d -f trash_file.txt >>
rx_ack_log.txt’ %(dest_addr, sender_addr, cmd, seqno)
os.popen(command)

thanks for the help!
regards,
-Sumit

python pipes are buffered. if your command produces a lot of output,
then the pipes can fill up, if you don’t read from them. One solution
is to move to the subprocess module:

subprocess — Subprocess management — Python 3.11.4 documentation

Cheers,

Thomas

On Sun, Apr 12, 2009 at 9:52 PM, [email protected] wrote:

See the python library reference for more info.

as follows:


Discuss-gnuradio mailing list
[email protected]
Discuss-gnuradio Info Page


“Don’t complain; Just work harder” - Randy Pausch

Thomas S., Ph.D. Candidate
Networked & Embedded Systems Laboratory (NESL)
University of California, Los A. (UCLA)