Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
As per the forum I'm a noob, looking for help writing a script that will play an audio file when a drive is mounted and another when a drive is unmounted.
It's RHEL 6, looking to use all native functions.. so i was thinking of using a .wav & play. Really need help with the alerting on drive mounts and unmounts part
Again, looking to use all native functions.. sox is installed so I plan on using the play command.. where I need help is the mount detection scripting.
I really don't know where to start there, so I can't tell you what I've tried wrt that.
Again, looking to use all native functions.. sox is installed so I plan on using the play command.. where I need help is the mount detection scripting.
I really don't know where to start there, so I can't tell you what I've tried wrt that.
Ok. Can you explain where you're stuck or what exactly you've done? Are you mounting any external device and want a script to detect that device and if that device contains any music files, then play it?
Without complete scenario, it will not be easy to suggest anything, and all it will be just a guess work. Hope this makes some sense now.
What I want to do is something similar to the windows world, where when a device is connected or disconnected a sound is played, one sound for device connections, one for disconnections. The sound files (.wav) would be present on the host filesystem, not the external drives. I'd like this notification to play regardless of the type of drive mounted, or where it was mounted from.
I know how to play the sound files using "play", where I'm stuck is where to begin with detecting drives being mounted. I'd like the script to be independent of any actions I'm taking.. so iow I'm not looking for something that will both mount a drive & play a file, I'm looking for distinct logic that will detect the mounts and unmounts and play the sound.. hope that's better.
---------- Post added 04-04-13 at 02:29 PM ----------
And sorry but I haven't done anything to give you an example thus far, I really don't even know where to start.
Thanks for taking the time to help me out, that looks like a good starting point and i think i would easily be able to write a script based off you guidance in this regard; however my concern is this:
The logic you provided as example depends on testing a condition on the mount point.. so I would need to constantly test the condition and thus it would constantly alert one way or another.. is there a better way to do it such that i'm detecting a change in state on the mount point?
Sorry, perhaps I'm missing something.. but how else would you be able to tell when the change happens in real time? say I've got other users on my system who are logged in and mount drives.. I want to know when that happens and if something is being mounted or unmounted.
I believe the UDev rule will accommodate this request and I have no experience in that arena.
And since I have no experience in that area, I'd be poorly guessing at what that process does
to make it work.
No problem, I still learned something new from what you posted and I appreciate that I just wanted to make sure I understood your last statement and wasn't missing something obvious there.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.