I’m need to create a Python shell script that refresh output every n seconds like top unix command.
what ‘s the best way to do this?
I’m need to create a Python shell script that refresh output every n seconds
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
One way to do this is to write a script that prints your output (once), and then run your script using the
watchcommand. Thewatchcommand will automatically clear the screen and run your script every few seconds (usually 2 by default).If you really want to do this in pure Python, you can use the
cursesmodule, or if you know your terminal is VT100-compatible you can go considerably simpler: