Python and .HTA files in IE5
Richard M. Smith
rms2000 at bellatlantic.net
Tue Apr 4 09:17:19 EDT 2000
Hello,
I am attempting to use Python as a scripting language in a .HTA
(HTML Application) file. .HTA files are executed by IE5 just
like .HTM files except that there are no secrutiy restrictions on
what script code can do. In a .HTA files, scripts can run programs,
read and write files, access the Windows registry, etc. They are usefull
for developing Windows applications that use IE5 for their user
interface.
I am having trouble executing the following simple Python script
to read the contents of AUTOEXEC.BAT and output it on
the .HTA page:
<script language=python>
myfile = open("c:\\autoexec.bat")
document.write(str(myfile.readlines()))
myfile.close()
</script>
I am getting an AttributeError in line 400 of
the file dynamic.py. It looks like the __getattr__
method is failing when the readlines method is
called by my script code.
Anyone know what is going on here and how to
fix the proble?.
A couple more data points here. If I rename the .HTA
file to have the .HTM extension, I get the identical error
message. This leads me to believe that the Python runtime
library isn't distinguishing between .HTA and .HTM files.
OTOH the equivalent .ASP file works fine:
<script language=python runat=server>
myfile = open("c:\\autoexec.bat")
Response.write(str(myfile.readlines()))
myfile.close()
</script>
Richard
More information about the Python-list
mailing list