My first script (so go easy on me!)
Oldayz
sill at localhost.kitenet.net
Tue Jan 16 21:35:07 EST 2001
More information about the Python-list mailing list
Tue Jan 16 21:35:07 EST 2001
- Previous message (by thread): My first script (so go easy on me!)
- Next message (by thread): My first script (so go easy on me!)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, 16 Jan 2001 15:50:17 GMT, Robert L Hicks <bobhicks at adelphia.net> wrote: >#!/usr/bin/python > >## ># This is a small script to cause the inetd daemon to re-read itself >## > >r = "kill -HUP `ps cax|grep inetd|awk '{print $1}'`" # restarts the daemon >n = "Inetd not restarted" >w = "Answer needs to be 'yes' or 'no'. Try again!" > >answer = " " > >query = raw_input("Do you want to restart the INETD daemon? (yes/no): ") #I'd do it like this: answer = raw_input("Do you want to restart the INETD daemon? [Y/n]: ") # Y is default, i.e. hitting enter is interpreted as yes # typing yes or no is really too much typing in this case > >if len(answer) > 2: > print r >elif len(answer) < 2: > print w >else: > print n if len(answer) == 0: os.system(r) # os.system runs the string.. elif answer[0] == 'y' or answer[0] == 'Y': os.system(r) elif answer[0] == 'n' or answer[0] == 'N': print n else: print w # I'm assuming r does what it's supposed to, I didn't test it.. nor the # code above Hope this helps. > > >Is this ok? My question is when the print statement is run do I need to do a >linefeed so the terminal accepts what was printed? Or does the fact that >python send the print to the terminal cause the terminal to execute it? > >How would you clean this up? > >Bob > -- Andrei
- Previous message (by thread): My first script (so go easy on me!)
- Next message (by thread): My first script (so go easy on me!)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list