Python Forum

Full Version: Python code error on browser.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have this code which works fine when i run it through terminal. But when i get to the link via browser, it gives me an error:
Quote:sh: hdfs: command not found
#!/usr/bin/python

import cgi
import cgitb
import os
import commands

cgitb.enable()

print "content-type:text/html"
print ""

print "--html--"
a=commands.getstatusoutput("hdfs dfs -ls -R /")
print a[1]
Can someone tell me why this is happening?
Output on terminal:
[Image: dFGqW.png]
I don't really understand what you mean by "i get to the link via browser,". Is the command run on the same or a different machine? by the same or a different userid? what are the environment variables (PATH, in particular)?

Not really a Python problem...
I'm using python cgi and running it on an httpd server.
Am i missing something in my code?? Is that why it's not working?
Same machine. Same ID. And the Path has the path to the hdfs command. I've already set that.
That's what i don't understand. It works fine if i run the script on terminal as "python script.cgi"
But opening it on the browser, i get that error.
Have the script echo $PWD $USER $PATH before launching the command...