Provide the full path to the python script, i.e.:
shell_exec('python /full/path/to/hello.py');
If you want to play safe, also provide the full path to the python binary.
shell_exec('/usr/local/bin/python /full/path/to/hello.py');
To find the full path to the python binary open the shell and type:
which python
- Make sure the apache user has execute permissions on
hello.py.
- I don't see any element with text "call another page" on your html.
Update:
You can also use python's SimpleHTTPServer, something like:
from BaseHTTPServer import BaseHTTPRequestHandler
import urlparse
class GetHandler(BaseHTTPRequestHandler):
def do_GET(self):
parsed_path = urlparse.urlparse(self.path)
self.send_response(200)
self.end_headers()
#self.wfile.write(message)
if (parsed_path.query == "LightON"):
from selenium import webdriver
driver=webdriver.Firefox()
driver.get("http://stackoverflow.com")
elem1 = driver.find_element_by_link_text("Questions")
elem1.click()
self.wfile.write("Command Executed")
return
if __name__ == '__main__':
from BaseHTTPServer import HTTPServer
server = HTTPServer(('localhost', 8080), GetHandler)
print 'Starting server, use <Ctrl-C> to stop'
server.serve_forever()
The above code will open a webserver on port 8080, and wait for a LightON request, after receiving it, executes the selenium code.
to activate it just create a link to it, something like
<a href="http://localhost:8080/LightON"> LightON </a>
PS: I've tested the code and it works as expected.
sudocommand? What shell are you using?pythonon%PATH%? What happens when you run the command in a regular command prompt?