0

Hi,

I have a Python script that calls a program that only prints to the terminal [yes I tried to force it to print to file ... no luck]. However, I need to save the output of the terminal to file in order to perform further analysis. In the code I tried running (the linux/unix command) script, via subprocess.call before the main code executes.

subprocess.call(["script", "scripttest.txt])
#Main Code starts
#and prints a lot of info to terminal
#Main code ends
subprocess.call("exit", shell=True)

However, while the python script successfully calls script, it "ends" before running the main code. The main code will only continue after I invoke CRTL-D (or type exit) to end script in the terminal, but doing this, the output isn't saved.

Does anyone have any ideas on how to get around this or another way to save the output?
I can copy from the terminal to file, however this is not efficient for many iterations!

Cheers,

Edited by halien

2
Contributors
1
Reply
23
Views
4 Years
Discussion Span
Last Post by vegaseat
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.