<br>
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:<br>
<br>
<br>
<div style="margin-left: 40px;">python search_interface.py device interface interface_name "is down - 00:00:00 01/01/06"<br>
</div>
<br>
<br>
Here is the script:<br>
<br>
<div style="margin-left: 40px;">
import ConfigParser, string, sys<br>
section = sys.argv[1]<br>
port = sys.argv[3]<br>
INI=ConfigParser.ConfigParser()<br>
INI.read("interfaces.ini")<br>
passwordentries=[p for p in INI.options(section)]<br>
passwordlist=[INI.get(section, pw) for pw in passwordentries]<br>
print passwordlist<br>
for i in passwordlist:<br>
if i == port:<br>
os.system("d:\\tnd\\bin\\cawto.exe -cat NetNet " + sys.argv[1] +
" " + sys.argv[2] + " " + sys.argv[3] + " " + sys.argv[4])<br>
</div>
<br>
<br>
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).<br>
<br>
<br>
<br>
Thanks!!<br>