LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-05-2014, 12:44 AM   #1
snowkitty
Member
 
Registered: Feb 2014
Distribution: kubuntu
Posts: 43

Rep: Reputation: Disabled
Using httpd/apache to play audio on server.


file.php
Code:
<?php
exec('script.sh');
?>
script.sh
Code:
#!/bin/sh
/usr/bin/aplay /msc/share/attention.wav
# which aplay
Code:
/usr/bin/aplay
/etc/apache2/apache.conf
Code:
# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
/etc/apache2/envvars
Code:
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
# groups www-data
Code:
www-data : www-data audio pulse pulse-access
Objective: Allow opening a webpage to play an audio file on the server, not on the client loading the page, but in order to make the server hosting system play an audio file. It is going to be a script opening the page, so the php script doesn't have reason to provide feedback or be more than a blank page, it's just means of executing a script to play audio on the server system.

Problem: I'm not sure what I am doing wrong here, or why this is not working, or if this is simply not possible. However, I am not able to get the audio file to play.

I'm open to suggestions of alternative methods of doing this same thing, but I have to do it over http, because it's the only means I have of making the client communicate with server.
 
Old 10-05-2014, 12:35 PM   #2
MisterBark
Member
 
Registered: Jul 2012
Location: Republic of Krakozhia
Distribution: Slackware & Zenwalk core + compile
Posts: 104

Rep: Reputation: 6
I believe that your script does not have the permission to play audio, OR, that your .sh file is not executable.

What is the output of:
Code:
ls -l script.sh
You should make a:
Code:
chmod 755 script.sh
Does this play the sound:
Code:
sudo ./script.sh
Does this play the sound:
Code:
sudo -u www-data ./script.sh

If none of these help, please try this:
Add "sleep 45" as the 2nd line of your script, which gives you:
Code:
#!/bin/sh
sleep 45
/usr/bin/aplay /msc/share/attention.wav
then load the page and as it is loading, type this:
Code:
ps auxm | grep -i script.sh
Do you see your script running? It should because you now have a 45 second sleep inside.
 
Old 10-05-2014, 01:20 PM   #3
snowkitty
Member
 
Registered: Feb 2014
Distribution: kubuntu
Posts: 43

Original Poster
Rep: Reputation: Disabled
Code:
# sudo -u www-data ./script.sh
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
aplay: main:722: audio open error: Device or resource busy
So here's the point of failure then. Now to just resolve that and everything should be working.


Edit: Found sollution.
It's not pretty, but it does what I need.
Code:
#!/usr/bin/expect -f
set force_conservative 0 
if {$force_conservative} {
        set send_slow {1 .1}
        proc send {ignore arg} {
                sleep .1
                exp_send -s -- $arg
        }
}
set timeout -1
spawn ssh snow@localhost -x exec aplay /misc/sounds/attention.wav
expect "*password*"
send -- "PASSWORD\r"
expect eof

Last edited by snowkitty; 10-05-2014 at 03:49 PM.
 
Old 10-05-2014, 05:35 PM   #4
MisterBark
Member
 
Registered: Jul 2012
Location: Republic of Krakozhia
Distribution: Slackware & Zenwalk core + compile
Posts: 104

Rep: Reputation: 6
haha... ok, then maybe that works?
Code:
sudo -u snow ./script.sh
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to see the Uptime of Apache httpd server nikeshp Linux - Software 2 02-24-2012 08:15 AM
apache server and httpd ust Linux - Software 2 02-12-2009 03:03 PM
Apache HTTPD server not connecting through internet. Moriya Linux - Newbie 5 04-09-2008 08:45 AM
configuration of httpd.conf to run apache server adityabhat2 Linux - Newbie 2 02-13-2005 12:10 PM
tomcat 5 implimentation on apache httpd server srikz Red Hat 0 07-22-2004 02:00 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration