[Tutor] (no subject)

Glen Bunting Glen@ihello-inc.com
Mon, 19 Mar 2001 13:42:42 -0800


Hi, 

I am trying to re-write a shell script that i have that checks for and
verifies specified content on an html page.  The following is the area that
I am having problems with:

 os.chdir('/sec/bb/ext/bb-hcheck/cfg')
    LIST = os.listdir(os.getcwd())
    for item in LIST:
        #NAME = 'cut --character=5- ' + item
        SERVER = os.popen('cut --character=5- ' + item).read()
        LOOK_FOR = os.popen('cut -- character=9- ' + item).read()
        #RESULTS = os.system('LYNX SERVER | grep LOOK_FOR')
        RESULTS_TEMPLATE = 'curl --include --max-time 30 %(server)s | grep
%(LOOK_FOR)s'
        RESULTS = RESULTS_TEMPLATE % {'server' : SERVER,
                                     'look_for': LOOK_FOR }
        FINAL = os.system(RESULTS)
        if [ RESULTS != 0 ]:
            COLOR = 'red'
            STATUS = 'Specified content:' +  LOOK_FOR + 'was not found'
        else:
            COLOR = 'green'
            STATUS = 'Successfully found ' + LOOK_FOR


running the program I get the following errors:
 ./bb-hcheck1.py
cut: you must specify a list of bytes, characters, or fields
Try `cut --help' for more information.
Traceback (innermost last):
  File "./bb-hcheck1.py", line 59, in ?
  File "./bb-hcheck1.py", line 34, in main
KeyError: LOOK_FOR

Does anyone have any idea what I'm doing wrong?  Am I taking the  right
track by trying to call the same program(curl,cut) that the shell script
uses, or should I be doing this completely differently? 

Thanks

Glen