Grabbing the output from the terminal
Question: I need to run a proccess in the terminal to grab the output from it.

    
    
    import subprocess
    subprocess.check_output(["my_util", "some_file.txt", " | grep 'Some data1' | awk '{print $2}'"])
    
    #or
    subprocess.check_output(["my_util", "full_path/some_file.txt", "| grep 'Some data1'", "| awk '{print $2}'"])
    

And nothing happens in REPL, while running it in the terminal manually gives
me the proper output.

update:

the output from sublime text:

    
    
    my_util FAIL formats: can't open input pipe `| grep 'Sample data1'': premature EOF
    my_util FAIL formats: can't open input pipe `| awk '{print $2}'': premature EOF
    Traceback (most recent call last):
      File "/test1.py", line 4, in <module>
        "| grep 'Sample data1'", "| awk '{print $2}'"])
      File "/usr/lib/python2.7/subprocess.py", line 544, in check_output
        raise CalledProcessError(retcode, cmd, output=output)
    subprocess.CalledProcessError: Command '["my_util", "full_path/some_file.txt", "| grep 'Some data1'", "| awk '{print $2}'"]' returned non-zero exit status 2
    


Answer: os.system can be used instead of subprocess

    
    
    import os
    
    os.system("my_util some_file.txt | grep 'Some data1' | awk '{print $2}'" )
    

