2

How can I execute this command using python's subProcess module

gunzip --name /tmp/file.gz > /home/aaaa/
Fanooos
  • 2,718
  • 5
  • 31
  • 55
  • 1
    I think [this](http://stackoverflow.com/questions/4856583/how-do-i-pipe-a-subprocess-call-in-python-to-a-text-file) would be a more appropriate dupe target. The problem here is more along the usage of the `>` to output to file. – idjaw Nov 11 '15 at 13:08

1 Answers1

0

You can use subprocess and redirect your output to a file:

import subprocess
output_file = open("/home/aaaa/myoutput", "w")
subprocess.call(["gunzip", "--name",  "/tmp/file.gz"], stdout=output_file)
Avihoo Mamka
  • 4,656
  • 3
  • 31
  • 44