Python code error on browser. - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Python code error on browser. (/thread-661.html) |
Python code error on browser. - adi.6194 - Oct-27-2016 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: RE: Python code error on browser. - Ofnuts - Oct-27-2016 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... RE: Python code error on browser. - adi.6194 - Oct-27-2016 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. RE: Python code error on browser. - Ofnuts - Oct-27-2016 Have the script echo $PWD $USER $PATH before launching the command... |