I have apache installed. If you don’t: sudo apt-get install apache2.

cd /usr/lib/cgi-bin

# Make a file and let everyone execute it
sudo touch test.sh && chmod a+x test.sh
Then put the some code in the file. For example:

#!/bin/bash
# get today’s date
OUTPUT=»$(date)»
# You must add following two lines before
# outputting data to the web browser from shell
# script
echo «Content-type: text/html»
echo «»
echo «<html><head><title>Demo</title></head><body>»
echo «Today is $OUTPUT <br>»
echo «Current directory is $(pwd) <br>»
echo «Shell Script name is $0»
echo «</body></html>»

We also have to enable mod_cgi a2enmod cgi if not already enabled

 

cat /etc/rc.local

echo «4» > /sys/class/gpio/export
echo «out» > /sys/class/gpio/gpio4/direction
echo «1» > /sys/class/gpio/gpio4/value

exit 0

 

cat /usr/lib/cgi-bin/on.sh
#!/bin/bash
# get today’s date
OUTPUT=»$(date)»
# You must add following two lines before
# outputting data to the web browser from shell
# script
echo «0» > /sys/class/gpio/gpio4/value
echo «Content-type: text/html»
echo «»
 

Вы должны войти на сайт, чтобы оставить комментарий.