My first script (so go easy on me!)

Quinn Dunkan quinn at chunder.ugcs.caltech.edu
Sat Jan 20 16:54:26 EST 2001


On Wed, 17 Jan 2001 02:35:07 GMT, Oldayz <sill at localhost.kitenet.net> wrote:
>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 = " "

...

>>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?

Here's how I'd do it:

#!/bin/sh

killall -HUP inetd


:)

Seriously, though, keep in mind that there are still things which are more
suitable for shell than python.  If you find yourself doing lots of pipelines
in strings and os.system()s, you're writing shell-in-python and might be
better served by just shell.

Yah, yah, I know it was just a learning excercise :)



More information about the Python-list mailing list