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 9565 articles. 4 followers. Post

1 Replies
238 Views

Similar Articles

[PageSpeed] 53


  • 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...

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...

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 ...

[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...

shell script to execute a kill command
I'm trying to figure out how to write a shell script to allow endusers to kill a process id. The problem is that the enduser may have to kill a process started by another enduser. I know I can't have them su to root from the script. How can I do this? On Wed, 25 Aug 2004 14:53:36 GMT, DH <my_generic_email@att.net> wrote: > I'm trying to figure out how to write a shell script to allow endusers to > kill a process id. The problem is that the enduser may have to kill a > process started by another enduser. I know I can't have them su to root > from the...

Executing a Unix shell script in Matlab
Hi, I'm wondering if there are any way of executing a Unix shell script in a matlab .m file. I have a number of resultfiles that are generated in other computational softwares. This files I have to preprocess with some awk -commands in a UNIX shell before I can load them into matlab. Is there a way to execute a script like this and have the matlab process wait for the result or do I have to do it all manually?? Greatfull for any hints on how to solve this... /Carl Hi Carl, have a look at the function system: >> help system Titus "Carl" <carl_sjoo@hotmail....

executing ssh from shell script #2
Hi, I have the following script on my client machine, which connects to the server using ssh. On the remote server there is a shell script which I want to execute. #!/bin/sh ssh root@10.10.1.180 ../testscripts/copyexecutable exit On the command prompt of the remote server the 'copyexecutable' script works perfectly fine. But when I try to run the above shell script on the local client, this is what I get.. [root@client DIR] $ ./test Last login: Wed Feb 27 16:33:39 2008 from 10.10.1.253 [root@server ~]# Then I hit a Ctrl-D and this is what I get Connection to 10.10.1.180 closed...

command not found when executing shell script
Hi, When I manually execute a shell script in /etc/init.d on my redhat linux server: /etc/init.d/cruisecontrol start /etc/init.d/cruisecontrol: line 1: : command not found I cannot see any errors on the first line of the script. Or? Cheers, //mikael This is the script: ==================== #!/bin/sh #content of /opt/cruisecontrol/init script # chkconfig: 345 99 05 # description: CruiseControl build loop (see /home/tools) # based on http://confluence.public.thoughtworks.org/display/CC/RunningCruiseControlFromUnixInit # adapted for multiple projects # # Cruise Control s...

Start a Terminal and execute a shell script
Hello, Hope that I am right here. I want to create a ".desktop" file, which starts a Terminal and executes a shell script. This shell script should set some environment variables and aliases and print an introduction message. I also need to know the path to the shell script and I want to define a working directory with the ".desktop" file. If I just create a ".desktop" file with "Terminal=true" and "Exec=bash /path/to/the/scriptfile", the Terminal closes immediately after it has been started. Therefore I added a "bash" command to t...