Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Python code error on browser.
#1
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:
İmage
Quote
#2
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...
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Quote
#3
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.
Quote
#4
Have the script echo $PWD $USER $PATH before launching the command...
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  How To Display this Python Code in Web browser? pradhan 1 269 Jul-14-2019, 06:59 PM
Last Post: snippsat
  How to fix error code 2 in python, “directory not found”? dav3javu 1 398 Apr-03-2019, 04:55 PM
Last Post: Larz60+
  Indentation error in Python code ErnestTBass 5 511 Feb-28-2019, 04:26 PM
Last Post: samsonite
  Can't find error in code but Python throws exception Sandwich_masterX 3 477 Oct-09-2018, 01:38 AM
Last Post: ichabod801

Forum Jump:


Users browsing this thread: 1 Guest(s)