#!/usr/bin/python3 import sys import getopt from lmwsip import LmwSip 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()