I have a PHP webpage on my raspberry pi with 2 buttons (on and off)
The on button button redirects to On.php
The off button redirects to Off.php
In "/usr/lib/cgi-bin" I have a python script that I would like to execute (script.py)
I can perfectly execute it from the terminal by typing

```
cd /usr/lib/cgi-bin
sudo python script.py

```

It works if I do it from the terminal.

The problem is the PHP file (On.php) in my "/var/www" folder.
This is what I wrote:

```
<?php
exec('cd /usr/lib/cgi-bin');
exec('sudo python script.py');
?>

```

Why is the script executing from the terminal, but not from my PHP?