Solved

/dev/audio

Posted on 1998-06-19
6
1,322 Views
Last Modified: 2013-12-16
Hi
Need some help with audio device in Solaris 2.4 running on sparc-10.
Using audioplay command in shell scripts to play warning sound under certain conditions.

# audioplay /usr/demo/SOUND/sounds/doorbell.au

Unless the script is run by root or the user who is currently logged in on the console then permission is denied for the audio device "/dev/audio". The audio device only has rw permission and is owned by the user who is logged onto the console.

# ls -l /dev/audio
lrwxrwxrwx   1 root     root          12 Feb  2  1997 /dev/audio -> /dev/sound/0
# ls -l /dev/sound/0
lrwxrwxrwx   1 root     root          42 Feb  2  1997 /dev/sound/0 -> ../../devices/audio@1,f7201000:sound,audio
# ls -l /devices/audio@1,f7201000:sound,audio
crw-------   1 <loginName>   sysadmin  28,  0 Feb  2  1997 /devices/audio@1,f7201000:sound,audio

The scripts are run by cron and cannot be run as root or as the user who is logged onto console.
The console login is always the same so to get round this for now I have added the following to the console login users .profile:
chmod g+w /devices/audio@1,f7201000:sound,audio.

However this will fail if the sparc is rebooted at any time without a login taking place on the console (a remote re-boot for example), as permission will be denied.

This is the question:
Is there any way to set the permissions of the audio device regardless of who logs into the console.
0
Comment
Question by:gormenghast
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:rickyr
ID: 1812150
Hi....
have you tried...
#chmod ugw+rw  /devices/audio@1,f7201000:sound,audio
I noticed that the character special is only read/write for root.
regards
0
 
LVL 3

Expert Comment

by:rickyr
ID: 1812151
Sorry...
Imeant ugo (user group other)................
0
 
LVL 2

Author Comment

by:gormenghast
ID: 1812152
Hi rickyr

The permissions and ownership for "/devices/audio@1,f7201000:sound,audio" is dependent on who logged onto the console, and any change of permissions or ownership will only be valid while that person is logged on.
For example:
boot up sparc and login in locally

login: fredf
password: •••••••
# ls -l /devices/audio@1,f7201000:sound,audio
     crw-------   1 fredf   sysadmin  28,  0 Feb  2  1997 /devices/audio@1,f7201000:sound,audio
# chmod 666 /devices/audio@1,f7201000:sound,audio
# ls -l /devices/audio@1,f7201000:sound,audio
     crw-rw-rw-   1 fredf   sysadmin  28,  0 Feb  2  1997 /devices/audio@1,f7201000:sound,audio

logout

login: barneyr
password: •••••••
# ls -l /devices/audio@1,f7201000:sound,audio
     crw-------   1 barneyr   sysadmin  28,  0 Feb  2  1997 /devices/audio@1,f7201000:sound,audio
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:seedy
ID: 1812153
>Is there any way to set the permissions of the audio device regardless of who logs into the console.

No.  Let me explain.  The audio device is a "speaker" housed in the main CPU box of the Sun machine.  And is considered part of the console - just like the keyboard, mouse and the display unit of the console.  That is the reason it is set to be owned by the user who is currently logged on to the console.

Imagine you telnet to the host via a network - miles away from the machine/console.  And if you play anything to the audio device, you can't hear anything, can you?

If your requirement is to play something to the audio device from a script run from crontab, you must be a root to change the permissions of the device and to 'write' to it.
0
 
LVL 2

Accepted Solution

by:
seedy earned 100 total points
ID: 1812154
Palying back to the console audio device from a cron job is not something I would like.  But then it may be is possible by some indirect way.

You can create another device node with the same major and minor device number as that of '/dev/audio' and use that device to play your audio files.

Find out device type and the major & minor device number of the audio device.
Do an "ls -l" to get this info.

From what you have posted, I see that your audio device is a charater special device with major number 28 and minor number 0(zero).
Now, create a new device with this info.
# mknod /devices/myaudio c 28 0
Set permissions to this device
# chmod 666 /device/myaudio

Use this device to play back your audio files in your scripts by
    audioplay -d /devices/myaudio <file>

0
 
LVL 3

Expert Comment

by:rickyr
ID: 1812155
Hello...
Run your script as root, then su to the user that will run the script,
Then su to the user that will ding the bell.
then su to the user that runs the script, to carry on with the script.
regards
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question