mrcheesypants
July 5th, 2008, 12:51 AM
Didn't know where exactly to put this, but I figured there would be more people familiar with my python problem in the programming forum than in a Linux forum. Anyway, I wrote an AIM bot in twisted worlds for a chatroom and it prints a lot of information as well as some error reports. I want to put in the errors in a file so it will be easier to debug.
A simple
./mycode > errors
causes two problems:
1) Prompts such as raw_input("Username:") do not show in the standard output but are saved to the errors file.
2) None of the errors are saved.
Just to make sure I'm stating my problem clearly, let me give an example script test.py
#!/usr/bin/python
print "Hello World!"
spam()
Now when I run the file, I get this output:
Hello World!
Traceback (most recent call last):
File "test.py", line 3, in <module>
spam()
NameError: name 'spam' is not defined
Now if I were to use
./test.py > error
Only the "Hello World!" would be saved to the file, and only the rest would be printed. What I want is for both to be printed, or atleast just the errors to be saved in a file.
A simple
./mycode > errors
causes two problems:
1) Prompts such as raw_input("Username:") do not show in the standard output but are saved to the errors file.
2) None of the errors are saved.
Just to make sure I'm stating my problem clearly, let me give an example script test.py
#!/usr/bin/python
print "Hello World!"
spam()
Now when I run the file, I get this output:
Hello World!
Traceback (most recent call last):
File "test.py", line 3, in <module>
spam()
NameError: name 'spam' is not defined
Now if I were to use
./test.py > error
Only the "Hello World!" would be saved to the file, and only the rest would be printed. What I want is for both to be printed, or atleast just the errors to be saved in a file.