Forum: GNU Radio os.popen broken pipe error

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ad0d35ab0738dcb7a5f60f51ee3a02ec?d=identicon&s=25 unknown (Guest)
on 2009-04-13 02:44
(Received via mailing list)
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
745d8202ef5a58c1058d0e5395a78f9c?d=identicon&s=25 Eric Blossom (Guest)
on 2009-04-13 06:11
(Received via mailing list)
On Sun, Apr 12, 2009 at 08:42:59PM -0400, satarkar@eden.rutgers.edu
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
Ad0d35ab0738dcb7a5f60f51ee3a02ec?d=identicon&s=25 unknown (Guest)
on 2009-04-13 06:56
(Received via mailing list)
>>
> 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
0dfa1a815559738fc7e0f17b0cbf9e54?d=identicon&s=25 Thomas Schmid (Guest)
on 2009-04-13 17:32
(Received via mailing list)
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:

 http://docs.python.org/library/subprocess.html#mod...

Cheers,

Thomas

On Sun, Apr 12, 2009 at 9:52 PM,  <satarkar@eden.rutgers.edu> wrote:
>>>
>> See the python library reference for more info.
>>>
> as follows:
> _______________________________________________
> Discuss-gnuradio mailing list
> Discuss-gnuradio@gnu.org
> http://lists.gnu.org/mailman/listinfo/discuss-gnuradio
>



--
"Don't complain; Just work harder" - Randy Pausch

Thomas Schmid, Ph.D. Candidate
Networked & Embedded Systems Laboratory (NESL)
University of California, Los Angeles (UCLA)
This topic is locked and can not be replied to.