Amixer doesn't work when executed in PHP
The ProblemI am building a web interface for my audio on Ubuntu Server 12.04. I want to mute the mic from my browser, however, the command exec("amixer sset 'Mic',0 mute"); worked only intermittently.
Tags: php, exec, amixer, system, passthru
The FixSummary: The problem is that the user www-data had in ufficient permissions to run amixer. To fix this you need to first determine the user that php uses:
echo exec('whoami'); Then I gave that user passwordless privelages to run one script under my account (jake): sudo visudo And insert this line, filling in your info: www-data ALL=(your username here - in my case jake) NOPASSWD: /home/jake/scripts/mute.sh Then I put the command that I wanted to run (amixer sset 'Mic',0 mute) in the mute.sh bash file. And I executed the script in PHP as shown below: exec("sudo -u jake /home/jake/Scripts/./mute.sh"); Now amixer mutes every time!
Additional Resources
There are no resources.
CommentsAdd a CommentThere are no comments. |
|||||||||||||||||||||||||||||||||||