Why not just pipe it directly?

python myScript.py > output.txt 2> errors.txt

will place any output (that is, print statements) in output.txt, and any errors 
(anything printed to stderr) to errors.txt. Of course, you can play with the 
paths or anything else you need. Or, you could put file-writing commands right 
in your script, using try/catch blocks to direct errors. Or, you could use 
Python's logging facility. It's up to you, but piping to files is probably the 
easiest, if the least flexible.
> On Jan 1, 2015, at 4:03 PM, DD <[email protected]> wrote:
> 
> 
> Someone asked:
> 
> "My problem is the following.
> I have a Python script to launch within the terminal.
> The script exits with a quite long and detailed error which has a long
> traceback.
> I would like to copy all this output from terminal in the clipboard in order 
> to
> past it within an e-mail, and asking help and suggestions to a programmer?s
> mailing list.
> 
> Now, this output comes up in terminal from stderr system file and I thought
> it?s possible to redirect it on a txt file before to launch the corrupted
> python script. So, it would be simple, than, to open that txt filed and save
> 
> it to the clipboard.
> 
> This for reading."
> 
> Me:
> 
> Sorry I have little experience with python.  Here is a page which seems to be 
> addressing a similar question:
> 
> http://stackoverflow.com/questions/4760215/running-shell-command-from-python-and-capturing-the-output
> 
> To get a clip board involved look at the "pbcopy and pbpaste" commands. These 
> allow multiple clip boards to be used from the command line.
> 
> Good luck.
> 
> XB


--
Have a great day,
Alex Hall
[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"MacVisionaries" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/macvisionaries.
For more options, visit https://groups.google.com/d/optout.

Reply via email to