Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am trying to run my python script while booting. In that time, the script is not working properly. But while run manually, I can see the terminal of script executing. But while run the same script as while boot, I couldn't find the script process. So,I found the tee command, but I don't know how to use this "tee" command in python.

share|improve this question
What part of the boot process runs this? I'm sorry, but I don't understand. How would the tee command help you? How would you use it? The tee command simply takes the output of one end of a pipe (standard input, or stdin), optionally outputs it to stdout (maybe the terminal, maybe more pipe), and meanwhile also writes the data to the files specified in its arguments. Is there any more detail you can provide about what you are trying to do? – John S Gruber Aug 13 '12 at 4:42
Dude,My script is running successfully while booting most of the times. But some time my expected result is not come properly while booting. So that only, I just put tee command in my script lines and write the file to that line execution details, May be this way is wrong to find the line execution. If you know any other way to find the error of script means kindly tell to me, I will use it. – Viswa Aug 13 '12 at 4:50
2  
And what does this have to do with Ubuntu? It sounds like a programming question better addressed on StackOverflow... – izx Aug 13 '12 at 5:04

closed as off topic by izx, Tachyons, jokerdino, ajmitch, fossfreedom Aug 20 '12 at 11:50

Questions on Ask Ubuntu are expected to relate to Ubuntu within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

2 Answers

If the /tmp file system is up when the script is run you can simply open an output file to, say, "/tmp/myscriptoutput" in python and write status to it. I've done that before when looking at upstart jobs.

Copy it off before the next boot (when /tmp is wiped out).

I suggest using /tmp because that file system should be ready for writing fairly quickly. If your script is running later in the boot process when the root file system is ready for writing you can open the file for writing somewhere else more permanent in that file system.

If your desire is to redirect the stdout of your print commands to a file without changing the print commands this answer from our stackoverflow sister site may help. It may be a good idea to redirect stderr as well since you know there may be some kind of error occuring in the script due to the boot environment. The related question may have more information of use to you as well.

share|improve this answer

Not sure if this is really what you are looking for, but to run system commands in python, you can do

import os
os.system("command here")

and run tee that way?

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.