1

I'm using python subprocess library to run command line in python file. After importing the library, I used following code to store the output

call(["python", "make.py", ">", "data"])

But for some reason, I didn't get data file

Haifeng Zhang
  • 30,077
  • 19
  • 81
  • 125
user2372074
  • 781
  • 3
  • 7
  • 18
  • I would say this answer is closer to what he wants: http://stackoverflow.com/a/3982683/2073595. Still, definitely a dupe. – dano May 30 '14 at 15:51

1 Answers1

1

You have to modify the stdout , check the official document subprocess

    import subprocess
    my_output_file = open("/home/user/output", "a")
    subprocess.call(["python", "hello.py"],stdout=my_output_file)
    my_output_file.close()
Haifeng Zhang
  • 30,077
  • 19
  • 81
  • 125