Newbie: Output From External App / Demon Mode w/ CL-Input

Julian Schäfer-Jasinski julschae at t-online.de
Mon May 28 14:36:45 CEST 2001


This one should be a rather basic topic. But I didn' t get it to work...

I am trying to write a script that verifies whether the machine is online
or not. Therefore I am trying to analyse the output of "ifconfig":

  os.execlp("ifconfig")

But how can I analyse the output. I tried redirecting the stream:

  sys.stdout=sys.stdin

(Probably a rather dumb approach?! - since it doesn' t work!).
How can this be done?

The other thing is - I want this script to run as demon. I didn' t
find anything about implementing demons in python. Therefore I thought
of something like:

while 1:
  do_pretty_cool_stuff()
  if done_enough:
    break()

But since there should also be a simple command-line interface for
manual termination / stats - do I have to use threads? (because
the script is waiting for an input?)

I tried to find some scripts using a similar technique - but wasn' t
very successful. Any ideas & comments are welcome...

Thanx for your input,

Julian




More information about the Python-list mailing list