New answers tagged python
0
Try running the following commands
chown root:root ./script
chmod 4775 ./script
0
If you don't mind programming in C, there's a working audio generation / playing sample in the /opt/vc/src/hello_pi/hello_audio folder:
cd /opt/vc/src/hello_pi/libs/ilclient
make
cd /opt/vc/src/hello_pi/hello_audio
make
./hello_audio.bin
It outputs audio to the headphone connector by default, but when used as ./hello_audio.bin 1 the output changes to ...
0
The command sudo python XYZ will be execute as the apache user. You'll need to add this user to your sudoers file.
sudo echo "apache ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
Replace "apache" with your systems apache username (may be "httpd" or "www" on some systems.)
Suggestion
Why use Apache or PHP at all? SimpleHTTPServer is extremely simple ...
1
sudo python /var/www/red_on.py most probably asks for a sudo password, which is not provided anywhere, and the command fails.
you may try echo <password> | sudo ..., however I haven't checked if output redirect works well in the PHP exec().
0
You'd be best implementing this in a C library, it could be trivially done with WiringPi and then wrapped in a Python wrapper to return the number of microseconds. I'd suggest a function prototype of:
timePin(GPIO_PIN,HIGH/LOW,TIMEOUT)
Where GPIO_PIN is the input we're watching, HIGH/LOW is the state we want to time, and TIMEOUT is the number of millis or ...
1
I'd suggest using cron to schedule the fan's on/off tasks.
Scheduling tasks can be managed by the crontab command.
shell ~> crontab -e
Add each on/off task. They would look something like:
0 9 * * * /path/to/your/python/script.py on
0 21 * * * /path/to/your/python/script.py off
The actual python script would be straight forward. Import sys to ...
Top 50 recent answers are included