Python Forum
Python code error on browser.
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:
[Image: dFGqW.png]
Reply
#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
Reply
#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.
Reply
#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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Code error from Fundamentals of Python Programming van Richard L. Halterman Heidi 12 1,602 Jul-25-2023, 10:32 PM
Last Post: Skaperen
  Syntax error while executing the Python code in Linux DivAsh 8 1,454 Jul-19-2023, 06:27 PM
Last Post: Lahearle
  Compiles Python code with no error but giving out no output - what's wrong with it? pythonflea 6 1,492 Mar-27-2023, 07:38 AM
Last Post: buran
  Error in if-then-else python code Led_Zeppelin 6 2,287 Jul-27-2022, 07:53 PM
Last Post: deanhystad
Question Opening small size browser with python selenium not work, need help greenpine 0 1,588 Feb-07-2022, 11:36 AM
Last Post: greenpine
  Facing error while executing below Python code ramu4651 1 5,634 Jan-26-2021, 06:40 PM
Last Post: ibreeden
  Skeleton file export error Python Code pepapoha 4 3,428 Nov-17-2020, 02:06 AM
Last Post: pepapoha
  Compiling Python 3.8.5 source code results in build error Deepan 0 2,146 Sep-14-2020, 04:11 AM
Last Post: Deepan
  Syntax error in python code sample ErnestTBass 5 3,060 Aug-14-2020, 07:14 PM
Last Post: deanhystad
  Error in Python Code ErnestTBass 4 2,676 Jun-04-2020, 05:28 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020