execute shell script on USB hotplug

  • Permalink
  • submit to reddit
  • Email
  • Follow


I would like to execute a shell script when a user plugs in a USB
storage device so I can automate the process of adding and removing
MP3s and other files.

The machine this is running on will be used only for adding and
removing MP3 files from USB storage, and will have a web-based GUI, if
that makes a difference.  (This will be a publically accessable kiosk)

I was hoping to find some more details on using the hotplug system
and/or udev in the hardware section.  Any ideas?

0
Reply oneseventeen (1) 10/28/2005 1:59:21 PM

See related articles to this posting


On 28 Oct 2005 06:59:21 -0700, oneseventeen@gmail.com staggered into the
Black Sun and said:
> I would like to execute a shell script when a user plugs in a USB
> storage device so I can automate the process of adding and removing
> MP3s and other files.

This sounds like a recipe for disaster to me.  What if the user's device
has a weird directory structure, a weird filesystem, or only 500K free?
Most automated processes like the ones you describe must make a large
number of assumptions, and if their assumptions aren't correct, they
tend to fail in interesting and stupid ways.  (Been There, Done That,
Got The T-Shirt.)

> I was hoping to find some more details on using the hotplug system

/etc/hotplug/ should contain a bunch of files that have a bunch of
comments in them.  On my Gentoo system, /etc/hotplug/usb/usbcam is a
shell script that executes when a USB camera that matches a large list of
device IDs is plugged in.  This script just does a chmod/chown to the
camera's device node so the currently-logged-in user can do stuff, but
it could be rearranged to do other things.  "man 8 hotplug" may also
provide info on the guts of the hotplug system.  HTH,

-- 
Matt G|There is no Darkness in Eternity/But only Light too dim for us to see
Brainbench MVP for Linux Admin /    mail: TRAP + SPAN don't belong
http://www.brainbench.com     /    "He is a rhythmic movement of the
-----------------------------/      penguins, is Tux." --MegaHAL
0
Reply danSPANceswitTRAPhcrows (1930) 10/28/2005 4:56:58 PM
comp.os.linux.hardware 9571 articles. 4 followers. Post

1 Replies
255 Views

Similar Articles

[PageSpeed] 42


  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

execute a shell script in a shell script
Please help. I have been stumbled on this issue, please see below. I am unable to execute a shell script in a shell script. I need to use perl script but not others and have tried eval, -exec and other on perl script but failed. system"cleartool setview -exec \"cleartool describe -fmt 'On %Sd modified %En and comment:\n %c\n\n' /myproject/vob/myprogram.C\" my_lag "; tks. On Dec 3, 8:30 am, moongeegee <moongee...@gmail.com> wrote: > Please help. > I have been stumbled on this issue, please see below. I am unable to > execute a shell script in a shel...

handling SIGINT in shell scripts when executing another shell script.
I have a simple shell script foo1.sh that invokes another shell script foo2.sh, something like below: #!/bin/sh SIGINT_handler() { echo "## [$DATE_TIME] User interrupt ignored," continue } trap SIGINT_handler 2 .... ../foo2.sh .... ---------- while executing foo1.sh, if the script receives SIGINT, how do I ignore the SIGINT in foo2.sh ? somehow foo2.sh does not finish to completion and is killed after receiving SIGINT. but foo1.sh is still executing. Is there any way to trap this signal in the child script. ? Please share your thots and inputs on this topic. Regards, Vikram S...

Execute shell script from a perl script
Hi, How can I executed a Unix shell script from a Perl script. The shell script is a dump of a oracle table to a file. The perl script is for the reformat of this output file. Thanks Karel J. Gleixner wrote: > kderaedt wrote: > >> Hi, >> >> How can I executed a Unix shell script from a Perl script. >> The shell script is a dump of a oracle table to a file. The perl >> script is >> for the reformat of this output file. > > perldoc -f system > Or if your perl script takes input from STDIN, and you modified your shell script...

execute a shell script from a python script
Hi all, I know nothing about Python. What I need to do is to get a Python script to execute a local shell script. I do not need any output. What would be th eeasiest way to accomplish this? Thanks! If your script is foo.sh and takes args: import subprocess subprocess.call(["foo.sh","args"],shell=True) Should work fine. check out http://www.python.org/dev/doc/maint24/lib/module-subprocess.html Enjoy, THN spec wrote: > Hi all, I know nothing about Python. What I need to do is to get a > Python script to execute a local shell script. I do not need any > output. ...

Execution of SQL Script thru shell script
hi all, I have a piece of SQL code(some insert statement). Unix server. Oracle DB. I need to execute the sql code in the unix shell ... as in as a part of a batch process... i have a loginid password... for oracle i believe that there is some sql command that can be embeded in the shell script ? ne one aware ? something like sqlplus username/password ... statement to execute sql file... i need exact syntax... Any help is appreciated ! regards iveanid@yahoo.com (Sridhar) writes: > I have a piece of SQL code(some insert statement). Unix > server. Oracle DB. I need to execute the s...

shell script with awk line that doesnt execute a further shell command
Hi Newbie-question. These lines work if executed from shell. wget -O "16" http://jumpcgi.bger.ch/cgi-bin/JumpCGI?id=03.08.2006_1P.455/2006 | sh wget -O "1" "http://jumpcgi.bger.ch/cgi-bin/JumpCGI?id=20.06.2006_K_28/06" | sh But within my bash-script it doesnt work. So there might be some escape sequence problems. The line is "produced" from a awk line in a bash script: awk -F[=\"\<\>] ' BEGIN { zaehler=0; } /HREF/ && /bger/ && /jump/ { link=$5 "=" $6; dnr=$6; zaehler++; print "wget -O " "\...

Executing shell scripts
Executing shell scripts: what the difference between executing shell scripts as "./x.sh" & ". ./x.sh" # ./myshell.sh & #. ./myshell.sh Thanks, bgane bg.bala@gmail.com wrote: > Executing shell scripts: > > > what the difference between executing shell > scripts as "./x.sh" & ". ./x.sh" > > # ./myshell.sh Executes the lines in myshell.sh in a subshell (so variablles being set there will not affect the current shell). > & > > #. ./myshell.sh Executes the lines in myshell.sh in the current shell...

Executing shell scripts
Executing shell scripts: what the difference between executing shell scripts as "./x.sh" & ". ./x.sh" # ./myshell.sh & #. ./myshell.sh Thanks, bgane bg.bala@gmail.com wrote: >Executing shell scripts: > >what the difference between executing shell >scripts as "./x.sh" & ". ./x.sh" > ># ./myshell.sh A subshell is spawned, and the commands in file myshell.sh are exectuted by that shell. The significance is that the commands executed in a subshell do not affect the environment of the parent proc...

Convert Bash shell script to Korn shell script
The following bash script works fine to delete all files that are older than $1 minutes. To execute this script, bash cleanup +10 find /mypath -type f -cmin $1 -exec rm -f {} \; Unfortunately, now I just realize I need to make it work in Korn Shell. Even I change the header from #!/bin/bash to #!/usr/bin/ksh, and execute the script by ksh cleanup +10, it still have different errors: cleanup[9]: -cmin: not found. cleanup[10]: -type: not found. Looks like it doesn't work anymore. I think I need to re-write the Korn Shell script that do the task. I tried to search for equivalent Korn ...

Convert Bash shell script to Korn shell script
The following bash script works fine to delete all files that are older than $1 minutes. To execute this script, bash cleanup +10 find /mypath -type f -cmin $1 -exec rm -f {} \; Unfortunately, now I just realize I need to make it work in Korn Shell. Even I change the header from #!/bin/bash to #!/usr/bin/ksh, and execute the script by ksh cleanup +10, it still have different errors: cleanup[9]: -cmin: not found. cleanup[10]: -type: not found. Looks like it doesn't work anymore. I think I need to re-write the Korn Shell script that do the task. I tried to search for equivalent Korn ...

Script executes script?
Hello, for a testmodule I need to execute a python script from within a python script. Something like: -- ScriptA --> import whatever RunScript("scriptb.py") RunScript("scriptc.py") <-- Script A -- Is this possible? I didn't find a possibility to do this. Would be nice if you could give me some advice here. Thank you, Mipe Hi ! Try execfile( On Wed, 01 Sep 2004 11:13:57 +0200, Michel Claveau - abstraction m�ta-galactique non triviale en fuite perp�tuelle. wrote: > Try execfile( Alternatively, on Unix at least, import os os.system('other....

Unable to execute shell script
Hi, I have a shell script written for ksh. Its execution permissions are correctly set for the current user. and the PATH also includes the entry for "."(current directory). But still i am not able to run the script from the command prompt. When I do myscript.sh or ./myscript.sh it says "file not found: myscript.sh". But the file is there in the current directory. Please help me. Thanks in advance. Gana Do you have the correct/format for ksh on the first line of the script? ganesh.m@gmail.com wrote: > Hi, > > I have a shell script written for ksh. Its execut...

Executing a Remote Shell Script
I'm attempting to run a remote shell script from my server on another workstation, but I keep getting the "not found" message anytime I attempt to run the script from my server, but can run it fine on the other server when I'm logged in. I'm using the following line in a local script to try and run the script remotely: remsh server -l user -n "cd /full/path/of/script/;ls;'callscript $host $dbase $rdg'" When the "ls" is called I can see the "callscript", but when the script is actually called I get: sh: callscript host dbase rdg: ...

executing ssh from shell script
Hi, I am trying to execute a shell script on a remote machine using a shell script on the local machine. I am not getting any errors but the remote script is not getting executed. Can you please tell me where I am going wrong. The local shell script is as follows. #!/bin/sh ssh root@10.10.1.180 ~/testscripts/copyexecutable exit The copyexecutable script works fine if I ssh into the remote machine and execute it from the command prompt. TIA, R C R C V wrote: > Hi, > I am trying to execute a shell script on a remote machine > using a shell script on the local machine....

executing a shell script with cron
hi all, i try to execute a backup-script daily via cron. therefore i edited the crontable with "crontab -e". i entered the following line: 30 2 * * * root /usr/local/scripts/backup.sh i want to run the backup-script every night 2:30am. if i log in as root and execute the script in the command line manually (bash-shell) all work fine! any idea whats wrong??? daniel TbBoss <tbboss@gmx.net> wrote: > any idea whats wrong??? No, how could we? What's the problem? It doesn't execute? It gives errors? What's the content of the script? Did you specified the whol...

execute shell script from java
Hi, I want to know if it is possible to execute a shell script from a java program. Johan Yes it is possible. "Johan" <me@knoware.nl> wrote in message news:1038j4qabcdbm40@corp.supernews.com... > Hi, > > I want to know if it is possible to execute a shell script from a java > program. > > Johan > > > > On Thu, 19 Feb 2004 06:41:44 +0100, "Johan" <me@knoware.nl> wrote: >Hi, > >I want to know if it is possible to execute a shell script from a java >program. > >Johan > > Runtime.getRuntime().exec(m...

Writing Shell script to interactively control another shell script??
Using Solaris, Say you want to write a shell script to control another simple menu entry shell script like the following testscript.sh file /////////////////////// themenu() { echo "MENU" echo "1 - Check Status and other stuff " echo "2 - Run program" echo "3 - Exit" echo "" } while true do themenu read input case $input 1) //check status and do some other stuff ;; 2) //start program and other background processes;; 3) break;; //exit loop and program *) ;; done ////////////////////////////////////////////////////////////////// What I wan...

how to execute a shell script on the desktop?
I have a shell script on the desktop that I want to double-click on and have execute. Currently when double-clicking on the icon the text editor opens with the shell script contents. How do I execute a shell script on the Desktop? The shell script does execute properly inside the Terminal. Mike In article <kBY4i.10$Qm3.6@newsfe03.lga>, Mike wrote: > I have a shell script on the desktop that I want to double-click > on and have execute. Currently when double-clicking on the icon > the text editor opens with the shell script contents. > > How do I execute ...

executing shell script in crontab
Hi, I tried to execute a shell script in crontab, but I don't see it is actually running periodically. Then I test it at the shell prompt: # /root/ntpdate.sh 1> /dev/null 2> /dev/null Ambiguous output redirect. The corresponding command written into the crontab file is: # crontab -l 5 * * * * /root/ntpdate.sh 1> /dev/null 2> /dev/null Is the syntax for executing this script not correct? Thanks Sam sam (sam++@--.com) wrote: > I tried to execute a shell script in crontab, but I don't see it is > actually running ...

How to execute a script from another script and other script does not do busy wait.
I want to run a python script( aka script2) from another python script (aka script1). While script1 executes script2 it waits for script2 to complete and in doing so it also does some other useful work.(does not do a busy wait). My intention is to update a third party through script1 that script2 is going to take longer. Please suggest how should I go about implementing it. I'm currently executing it as: import main from script2 ret_code = main() return ret_code which surely is not going to achieve me what I intend. Thanks, Rajat. =20 Use threads Regards, ...

[OT] How do I execute script in different shell?
Hi, Sorry to post an off topic question, but it's a quick one, hope you can help. Say I have a shell script shell.sh: $!/bin/sh echo $SHELL From a bash shell, how do I get bash to execute the script ksh to execute the script sh to execute the script Yes, if it's not obvious already, it's a question from Computer Science course. The answers weren't available, so I wasn't sure if I got it correct or not... Sorry for the bother, hope you can help Thanks Robo * Robo; Fri, 7 Nov 2003 02:38:13 +1300 > Say I have a shell script shell.sh: > > $!/bin/sh > ec...

IS IT POSSIBLE TO EXECUTE A SHELL SCRIPT TO TO THE FOLLOWING
IS IT POSSIBLE TO EXECUTE A SHELL SCRIPT TO TO THE FOLLOWING: I would like to run different executables depending on the OS. If I am on windows (see bash below) I would like to execute c:/cygwin/usr/local/bin/tclkitsh.exe and if I am on Linux, execute /usr/local/bin/tclkit I will be running a bash script on my webserver with the following choices: bash shells are either at: /cygdrive/c/cygwin/bin/bash.exe (windows) or /bin/bash (linux) Many thanks for your help In article <1190640550.429459.61650@22g2000hsm.googlegroups.com>, Rivotti <MelHeravi@gmail.com> wro...

How to display the each executed line of a shell script?
When I start (in ksh) a shell script test.sh How do I let the shell interpreter display each line he will execute just before he is really executing it. The display should include the real content of variables. Matt Am Wed, 9 Feb 2005 01:05:20 +0100,schrieb Matt Benson : > When I start (in ksh) a shell script test.sh > How do I let the shell interpreter display each line he will execute > just before he is really executing it. > The display should include the real content of variables. > set -x tschazu erkan -- �ber den grenzen mu� die freiheit wohl wolkenlos sein On ...

Execute a shell script by double clicking
Hi everyone.. very simple question. I have a shell script... it uses my screensaver as my background, which I find to be very cool. The goal is to, as easily as possible, and with no extra windows being open, start the process. RIght now, I have to go into terminal, go into screen, and start the process. [I need to go into screen so that I can close Terminal -- remember I don't want any open windows] I just want to doubleclick something on my Desktop to have it open. Here's the script: !#/bin/sh /System/Library/Frameworks/ScreenSaver.framework/Resources/ ScreenSaverEngine.app/Con...