Hello All i want to loop this script til i stop it. how can i do that ??
i have made
PaulCode:import os import time os.system("clear") os.system("sudo virsh -c qemu:///system list")
Hello All i want to loop this script til i stop it. how can i do that ??
i have made
PaulCode:import os import time os.system("clear") os.system("sudo virsh -c qemu:///system list")
Last edited by PaulNL; March 7th, 2013 at 04:09 PM. Reason: add code
Something like this?
Code:import time while True: print 'Hello' time.sleep(1)
Please create new threads for new questions.
Please wrap code in code tags using the '#' button or enter it in your post like this: [code]...[/code].
when i use that i get an error IndentationError: expected an idented block
i have made a second script to work with the first script
i cant get it all in the same fileCode:while true; do python status.py ; sleep 5s ; done
Last edited by PaulNL; March 7th, 2013 at 03:22 PM.
Just do it in Python, there's no need for a calling script.
Python needs the content of the loop indented consistently, i.e. the same number of spaces for each line within the indent.
I've added the shebang line at the top so it runs as a script. Don't forget to 'chmod +x'.Code:#!/usr/bin/env python import os import time while True: os.system("clear") os.system("sudo virsh -c qemu:///system list") time.sleep(5)
Last edited by r-senior; March 7th, 2013 at 03:33 PM.
Please create new threads for new questions.
Please wrap code in code tags using the '#' button or enter it in your post like this: [code]...[/code].
when i use your script i get an error se thread above
The TAB/space characters could get messed up when pasting from the browser window. Delete the spaces, and re-insert them manually.
Works Thanks
Last edited by PaulNL; March 7th, 2013 at 04:08 PM. Reason: Case Closed
Bookmarks