[Freeswitch-trunk] [commit] r12729 - freeswitch/trunk/libs/esl/python

FreeSWITCH SVN brian at freeswitch.org
Tue Mar 24 08:00:44 PDT 2009


Author: brian
Date: Tue Mar 24 10:00:44 2009
New Revision: 12729

Log:
ESL-9

Modified:
   freeswitch/trunk/libs/esl/python/single_command.py

Modified: freeswitch/trunk/libs/esl/python/single_command.py
==============================================================================
--- freeswitch/trunk/libs/esl/python/single_command.py	(original)
+++ freeswitch/trunk/libs/esl/python/single_command.py	Tue Mar 24 10:00:44 2009
@@ -2,21 +2,42 @@
 
 import string
 import sys
+from optparse import OptionParser
 from ESL import *
 
-con = ESLconnection("localhost","8021","ClueCon")
-#are we connected?
-
-if con.connected:
-
-	#get argument passed to script
-	command = string.join(sys.argv[1:])
-
-	#run command
-	e=con.sendRecv("api "+  command)
-	print e.getBody()
-
-else:
-
-	print "Not 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")
+
+		(options, args) = parser.parse_args()
+
+			
+		con = ESLconnection(options.server, options.port, options.auth)
+	#are we connected?
+
+		if con.connected:
+			#run command
+			e=con.sendRecv("api "+  options.command)
+			print e.getBody()
+
+		else:
+
+			print "Not Connected"
+			sys.exit(2)
+
+	except:
+		
+		print parser.get_usage()
+		
+if __name__ == "__main__":
+    main(sys.argv[1:])
\ No newline at end of file



More information about the Freeswitch-trunk mailing list