1

I am calling an executable from a python script using subprocess and later doing couple of stuff on the file that the executable gives as output, by reading it separately. Is it possible to catch this output file as a file object or by any other method, and not have the file created?

Edit: I'm on Xubuntu and I am a beginner at bash scripting. The executable reads two files from a directory (path known, but separate from the one where my code is), and writes one output file there itself. I can't pipe std output instead of reading the file.

  • 1
    @Coldspeed don't be so hasty. There are tricky things you can achieve with files, depending upon your setup. – Peter Wood Jun 11 '17 at 22:13
  • @PeterWood You mean something like redirecting all output to `subprocess.Popen`? – cs95 Jun 11 '17 at 22:15
  • @PeterWood I will be creating thousands of files because of that third party executable. Wouldn't it be better if I can get the file information directly, rather than reading it separately, then deleting each file once I am done with it? – blehblehblecksheep Jun 11 '17 at 22:22
  • This is a very broad question. What operating system are you on? Can you specify where files are written? Can you pipe std output instead? Lots of loose ends. See [ask]. – Peter Wood Jun 11 '17 at 22:24
  • this question is a duplicate of this one: (https://stackoverflow.com/questions/43302064/binding-piping-output-of-run-on-into-function-in-python3-lynux/44488295#44488295) of mine – Tomas Jun 11 '17 at 22:26
  • @PeterWood Sorry. I'm on Xubuntu and I am a beginner at bash scripting. The executable reads two files from a directory (separate from the one where my code is), and writes one output file there itself. I can't pipe std output instead. – blehblehblecksheep Jun 11 '17 at 22:30
  • @Tomas Is it? I can't get the file info from stdout, unlike you. – blehblehblecksheep Jun 11 '17 at 22:34

0 Answers0