I have some code here:

import urllib
import subprocess
import time

open_site=urllib.urlopen("http://www.freewebs.com/sravan953/command_python.html")
read_site=open_site.read()

site_list=[]

for a in read_site:
    if a=='<':
        break
    elif a!='<':
        site_list.append(a)

site_list.remove('\n')
site_list.remove('\n')
site_list.remove('\r')

for a in site_list:
    site_string=''.join(site_list)

def run_program():
    current=time.asctime()
    print 'Runnning program'+' ['+current+']'
    subprocess.call(site_string)

def check_argument():
    current=time.asctime()
    if str=='':
        print 'No command given'+' ['+current+']'
        timer()
    else:
        print 'Command found...'+' ['+current+']'
        run_program()

def timer():
    current=time.asctime()
    print 'Checking for commands...'+' ['+current+']'
    time.sleep(30)
    check_argument()

timer()

How can I intervene the loop, like at any time if the user enters 'QUIT', the program has to stop...any ideas on how I can go about this?

Thanks

My first thought would be to use a separate thread to handle a function waiting for user input. Then if it receives the signal to quit, it terminates the program. You can use the threading module to accomplish this.

I don't know if this is considered to be a no no in terms of "good programming" but I think it would work. Anyone else have a good idea?

Consider the shadwickman's saying.
But easy answer is use of break to terminate the loop. any loop can be exite anytime using break statement

Yes, evstevemd, but if there is a raw_input statement waiting for the user to type "break" or "exit", it will hold up the rest of the script from executing until it has received input. He wants the loop to run while also waiting for user input in case they want to break it. That's why I suggested a thread.

Your problem can best be solved by going to GUI programming (has an event loop) and have the user click a button to quit.

and consider wxPython as to my HO is the best toolkit. I'm waiting for PyQT to switch to LGPL Like its father QT. Until then I recommend wxPython.
www.wxpython.org

For simple stuffs, Old good TkInter might help! :)

This question has already been answered. Start a new discussion instead.