diff --git a/hoek-h10.sip b/hoek-h10.sip new file mode 100644 index 0000000..3051643 --- /dev/null +++ b/hoek-h10.sip @@ -0,0 +1,4 @@ +LI USER,PASS +TI LMW +WN LMW,HOEK,H10,-01:00,12-02-2019,22:00,DATA +LO diff --git a/siprun b/siprun index a67f575..d5f699a 100755 --- a/siprun +++ b/siprun @@ -1,8 +1,46 @@ #!/usr/bin/python3 +import sys +import getopt from lmwsip import LmwSip -lmwsip = LmwSip("NAGIOS", "NAGIOS") -print(lmwsip.ti()) -print(lmwsip.value("WN", "HOEK", "H10")) -lmwsip.logout() +def usage(): + print("siprun [-s] [-h ] [-p ] []") + print("\t-s: SSL connection") + print("\t-h : Connect to host") + print("\t-p : Connect to port") + print("\t-: LMW commando files") + +def main(): + try: + opts, args = getopt.getopt(sys.argv[1:], "sh:p:", ["help", "output="]) + except getopt.GetoptError as err: + # print help information and exit: + print(err) # will print something like "option -a not recognized" + usage() + sys.exit(2) + ssl=False + host=None + port=None + for o, a in opts: + if o == "-s": + ssl=True + elif o == "-h": + host=a + elif o == "-p": + port=a + if (host==None or port==None): + print("Set host and port") + usage() + sys.exit(3) + lmwsip = LmwSip(ssl=ssl, host=host, port=port) + for cmdfile in args: + with open(cmdfile, "r") as f: + for cmd in f: + print("> [%s]" % (cmd.strip('\n'))) + lmwsip.send(cmd) + print("< [%s]" % (lmwsip.recv().decode('utf-8').strip('\r'))) + f.close() + +if __name__ == "__main__": + main()