Menu

hangup extension in python prevents ncid server from starting

Dan Essin
2023-01-16
2023-01-16
  • Dan Essin

    Dan Essin - 2023-01-16

    Hello,
    My goal is to create a hangup extension that extracts several fields from the input string and searches for a match is a file containing a list of key words. I'm doing this in python because i'm more familiar with that than shell scripting.

    If I enable one of the sample extensions by editing ncidd.conf, the server restarts successfully after the edit.
    If I enable a simple python script that works when executed at the command line, the server refuses to start. The failure message is of no use.

    I know that the manual says that extensions can be written in any language as long as they return hangup or ok via stdout, so I'm confused about why this simple test program in python interferes with the server even starting.

    I have pruned my original code to this (which is sufficient to prevent the server from starting):
    #!/usr/bin/ python3
    --or--
    #!/usr/bin/env python3
    --neither work--
    import sys
    if name == "main":
    num_args = len(sys.argv)
    try:
    print ("Number of the arguments: ", num_args)
    arg_text = sys.argv[1]
    print((arg_text))
    except IndexError:
    arg_text = ""
    except:
    exit()

    I could really use some help on this.
    Thank you

     
  • Ed Attfield

    Ed Attfield - 2023-01-16

    As ncidd starts, it checks to see if the hangup extension exists, is named hangup-something, and is executable.
    In unix, "executable" refers to the file's permission bits, which can be examined with ls -l and set with chmod 755 hangup-something.
    ncidd invokes the hangup script with /bin/sh -c hangup-something, which you might try out to make sure it runs the python interpreter.
    Adding set verbose=4 to ncidd.conf will log more information when the hangup script ends.

     

Log in to post a comment.