start script if specific usbdevice gets plugged in

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read this

start script if specific usbdevice gets plugged in

Postby mr.f on Wed Jun 24, 2009 5:17 am

Hi everybody,

I want to start a script if a usb device with a specific id/uuid gets plugged in.
I searched a lot, but couldn't find how to do that.
Does anyone have an idea?

Thx
Mr.F
mr.f
Level 1
Level 1
 
Posts: 3
Joined: Wed Jun 24, 2009 4:22 am

Linux Mint is funded by ads and donations.
 

Re: start script if specific usbdevice gets plugged in

Postby Husse on Fri Jun 26, 2009 11:47 am

This is a bit tricky
When you plug in a pen drive the number of items in /dev increases - actually by 6 for a one partition drive
I don't know which files, so I don't know if you see UUID in any
/etc/mtab is also changed - but it's not using UUID
/media is changed - again no UUID
I would suspect something happens in /proc as well
and of course there is dmesg, but no UUID there either
Time to google - but for what? Can't think of a useful search phrase...
So in essence - I could tell you how to start a script if something was plugged in into USB, but not if it is to be a specific device
Looking at dmesg I see that the size is mentioned, that might be used - trigger an event if a drive of a particular size is plugged in
Image
Don't fix it if it ain't broken, don't break it if you can't fix it
Husse
Level 21
Level 21
 
Posts: 19703
Joined: Sun Feb 11, 2007 7:22 am
Location: Near Borås Sweden

Re: start script if specific usbdevice gets plugged in

Postby mr.f on Sun Jun 28, 2009 8:47 am

thx for the hints.
maybe looking for a specific file on the drive is the easiest way..
I want to use it in combination with truecrypt. so if there is the container with my keyfile on that device, run my script to mount that container and use the keyfile to mount local encrypted partitions.
I could tell you how to start a script if something was plugged in into USB

That would be great!
Thx, Mr. F
mr.f
Level 1
Level 1
 
Posts: 3
Joined: Wed Jun 24, 2009 4:22 am

Re: start script if specific usbdevice gets plugged in

Postby Husse on Sun Jun 28, 2009 1:23 pm

a script if something was plugged in

but not necessarily in USB, but what else could it be.
Watch mtab - if mtab changes something is plugged in - or out
File size is probably the simplest - I haven't tried it so I'll have to leave the details to you
Image
Don't fix it if it ain't broken, don't break it if you can't fix it
Husse
Level 21
Level 21
 
Posts: 19703
Joined: Sun Feb 11, 2007 7:22 am
Location: Near Borås Sweden


Return to Newbie Questions

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 18 guests