subprocess.popen stdout pipe

This is the place for queries that don't fit in any of the other categories.

subprocess.popen stdout pipe

Postby aaron.tanenbaum » Fri May 17, 2013 4:14 pm

I am currently writing a programs that runs cshell and bash scripts created by other people. i am using subprocess.popen to call these scripts. some of these scripts have large stdout outputs exceeeding 64k which apparently is an issue for this function causing it to hang. i would like to capture the ouptut. are there better alternitives
aaron.tanenbaum
 
Posts: 2
Joined: Fri May 17, 2013 3:46 pm

Re: subprocess.popen stdout pipe

Postby setrofim » Fri May 17, 2013 5:52 pm

You can try redirecting your output to a file and then reading it form there. Something like
Code: Select all
subprocess.call("your_script.sh > /tmp/your_output.out", shell=True)

followed by
Code: Select all
with open("/tmp/your_output.out") as fh:
    text = fh.read()
setrofim
 
Posts: 288
Joined: Mon Mar 04, 2013 7:52 pm

Re: subprocess.popen stdout pipe

Postby aaron.tanenbaum » Mon May 20, 2013 9:01 pm

Thank you dude. it did the trick
aaron.tanenbaum
 
Posts: 2
Joined: Fri May 17, 2013 3:46 pm


Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 3 guests

cron