Em Ter, 2006-03-28 às 18:14 -0800, [EMAIL PROTECTED] escreveu: > It will need a Ctrl-C in order to break out of the program. > I wish to run this program using python (either thru os.system() or > some other subprocess modules) and how can i pass Ctrl-C to this > program to terminate it in python?
$ python2.4 && echo " **** Python terminates!" Python 2.4.2 (#2, Mar 27 2006, 21:07:39) [GCC 4.0.3 (Debian 4.0.3-1)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> ^C KeyboardInterrupt >>> try: ... while 1: ... pass ... except KeyboardInterrupt: ... print "\nHey, why did you press Ctrl-C?!" ... except: ... print "\nStrange..." ... ^C Hey, why did you press Ctrl-C?! >>> import sys >>> try: ... while 1: ... pass ... except KeyboardInterrupt: ... sys.exit(0) ... ^C **** Python terminates! $ HTH, -- Felipe. -- http://mail.python.org/mailman/listinfo/python-list