From 80e6a1bd0fab6882a0e48277f6b23cbf9de0bf31 Mon Sep 17 00:00:00 2001 From: Brian West Date: Tue, 24 Mar 2009 15:00:44 +0000 Subject: [PATCH] ESL-9 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12729 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- libs/esl/python/single_command.py | 41 +++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/libs/esl/python/single_command.py b/libs/esl/python/single_command.py index 977ec9660d..4f1f0ea59a 100644 --- a/libs/esl/python/single_command.py +++ b/libs/esl/python/single_command.py @@ -2,21 +2,42 @@ import string import sys +from optparse import OptionParser from ESL import * -con = ESLconnection("localhost","8021","ClueCon") -#are we connected? +def main(argv): + + try: + + parser = OptionParser() + parser.add_option("-a", "--auth", dest="auth", default="ClueCon", + help="ESL password") + parser.add_option("-s", "--server", dest="server", default="127.0.0.1", + help="FreeSWITCH server IP address") + parser.add_option("-p", "--port", dest="port", default="8021", + help="FreeSWITCH server event socket port") + parser.add_option("-c", "--command", dest="command", + help="command to run, surround mutli word commands in \"\'s") -if con.connected: + (options, args) = parser.parse_args() - #get argument passed to script - command = string.join(sys.argv[1:]) + + con = ESLconnection(options.server, options.port, options.auth) + #are we connected? - #run command - e=con.sendRecv("api "+ command) - print e.getBody() + if con.connected: + #run command + e=con.sendRecv("api "+ options.command) + print e.getBody() -else: + else: - print "Not Connected" + print "Not Connected" + sys.exit(2) + except: + + print parser.get_usage() + +if __name__ == "__main__": + main(sys.argv[1:]) \ No newline at end of file