[Tutor] ASP And Python - Calling Python Scripts from within the web page

Gooch, John John.Gooch at echostar.com
Thu Aug 4 21:07:05 CEST 2005


I have basic Python functions working within ASP pages, but I am having
problems passing arguments to python scripts when they are called. Here is
what I have so far:


---------------------------------
<%@ Language = Python%>
<%

import os	
import sys
sys.path.append("d:/batch2000")
import chgpwd_enq
import chgpwd

def initialize():
	global arUserNames
	global strUserNames
	arUserNames = Request.QueryString("u")
	strUserNames = ",".join(arUserNames)
	return None
def main():
	try:
		error = initialize()
		if ( not error ):
			#transid = Server.Execute(
"d:\batch2000\chgpwd_enq.py -u " & strUserNames )
			for name in arUserNames:
				Response.write( name + "<br>" )
	except Exception,error:
		Response.write( "Error Occured." + str(error))
	sys.argv = [ 'junk', '-u jgooch.admin' ]
	#os.system( "d:/python/python.exe d:/batch2000/chgpwd_enq.py -u
jgooch.test" )
	transid = chgpwd_enq.main()   # enqueue users and get the
transaction id
	Response.write( "Transactionid=" + str(transid) + "<br>" )
	return 0
main()
------------------------------------------

Transaction ID is None. If I run the "chgpwd_enq.py" script in a command
window, it works fine. But it is not doing anything when run as from the ASP
page.

I am guessing that the sys.argv is not working as intended, but it is hard
to tell as I am not getting any response from the called Python script. 

Any ideas? 


More information about the Tutor mailing list