Solved

/dev/audio

Posted on 1998-06-19
6
1,317 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
Technology Partners: 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

742 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