Unable to execute system program

Chris chouster at uclink4.berkeley.edu
Fri May 31 17:17:34 EDT 2002


NOTE: Sorry if this appears twice, there was an error when I posted it
the first time so i just went ahead and did it twice.

Hi everyone. I'm trying to run an external script from my CGI script.
When I do some tests it seems like it doesnt run at all because the
output that SHOULD be coming out of the external script isnt. However
when I run via the command line, it works fine... it takes about 60
seconds. When I run it via web test, it takes less than a second which
strongly suggests it's not running ti at all. I programmed the script
to drop a file with the output upon execution. Doing so from the
command line does as it should but web testing results in nothing. Can
someone tell me why it seems like it's not executing properly?

NOTE: Html is my own lil module I wrote, that is working fine and I
know it's not the problem.

===CODE===

if (os.fork() == 0):
		os.system("myCommand") #have faith that myCommand is correct.
		print "If I see this it should mean that the process was run."
		print Html.linebreak()  #prints newline in HTML format
		os._exit(0)

	else:
		# controlling parent process
		while 1:
			# check if child has exited, but don't block
			(pid, status) = os.waitpid(-1, os.WNOHANG)
			if pid > 0:
				print Html.startHtml("doing request..."), \
				      "Process completed!", \
				      Html.linebreak(), \
				      Html.endHtml()
				break
			else:
				print Html.startHtml("Doing request..."), \
				      ".", \
				      Html.endHtml()

				time.sleep(1)
                ...
                ...



Since my external script takes a minute or two, I think perhaps that I
should add an extra time.sleep(60) statement on the line right before
I call the actual execution of the external script. Or perhaps on the
line after, I'm confused on this and am not sure if this is correct at
all. Here is the output

---OUTPUT---
Please wait while we process your request. . . . If I see this it
should mean that the process was run.
Process completed! 

-------------

I dont know why it seems like it's not executing. Please help!!

Chris



More information about the Python-list mailing list