Python Forum
Controlling what get outputted to stdout when running external commands
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Controlling what get outputted to stdout when running external commands
#4
(Jan-29-2022, 07:21 PM)bowlofred Wrote: I wonder if some of this is because the console is getting both stdin and stderr.

If you run handbrake [options....] > /dev/null do you get the output you're trying to ignore? If so, (and if you don't need the stderr information), then try adding stderr=subprocess.DEVNULL to have that stream ignored.

If you do need to parse the stderr stream, then setting it to stderr=subprocess.STDOUT should work to combine them.

I put the stderr stream inline with the stdout stream like shown above and that woked.
p = subprocess.Popen(command, stdout=subprocess.PIPE, text=True, stderr=subprocess.STDOUT)
Is there any reason as to why its is hard to capture two or three streams? If you have any good resorces on the topic I would a greatly aprecate it if you could send them my way.
Reply


Messages In This Thread
RE: Controlling what get outputted to stdout when running external commands - by Daring_T - Jan-30-2022, 04:06 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem running external process rjdegraff42 0 296 Mar-19-2025, 07:50 PM
Last Post: rjdegraff42
  subprocess_run and stdout flux paul18fr 2 525 Jan-09-2025, 08:50 PM
Last Post: Gribouillis
  How to make it so whatever I input into a script gets outputted on a different file spermatozwario 4 1,131 Nov-24-2024, 12:58 PM
Last Post: deanhystad
  Failing to iterate over captured StdOut tester_V 4 1,509 Jul-12-2024, 03:36 PM
Last Post: deanhystad
  [subprocess] Why stdout sent to stderr? Winfried 3 2,049 Jan-26-2024, 07:26 PM
Last Post: snippsat
  Controlling program with TCP commands lavacode 1 1,082 Jul-10-2023, 04:39 PM
Last Post: deanhystad
  Performance options for sys.stdout.writelines dgrunwal 11 6,097 Aug-23-2022, 10:32 PM
Last Post: Pedroski55
  execute commands inside a running application mr_byte31 3 2,163 Apr-12-2022, 08:50 AM
Last Post: Larz60+
  Controlling text-to-speech pauses with pyttsx3 pmac1300 4 7,049 Mar-14-2022, 06:47 AM
Last Post: Coricoco_fr
  changing stdout and stderr Skaperen 4 3,998 Dec-02-2020, 08:58 PM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020