[Tutor] script question

Chris Hallman challman at gmail.com
Mon Sep 26 13:56:32 CEST 2005

I needed a script that takes command line arguments, searches an ini file
for a match to the arguments and then executes a Windows executable. This is
my first script using python so I wanted to make sure I made the most of the
language. I took bits and pieces from different tutorials and examples
online. The script is executed in this manner:

python search_interface.py device interface interface_name "is down -
00:00:00 01/01/06"

Here is the script:

 import ConfigParser, string, sys
section = sys.argv[1]
port = sys.argv[3]
passwordentries=[p for p in INI.options(section)]
passwordlist=[INI.get(section, pw) for pw in passwordentries]
print passwordlist
for i in passwordlist:
if i == port:
os.system("d:\\tnd\\bin\\cawto.exe -cat NetNet " + sys.argv[1] + " " +
sys.argv[2] + " " + sys.argv[3] + " " + sys.argv[4])

I'd like to know if there is a more efficient way to do this and if there is
a way to have these functions performed with the least amount of time
possible (the ini file could grow quite large).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20050926/42fb29b6/attachment.htm

More information about the Tutor mailing list