run script afer usb device pluged in

Hi

this might be a little stuip question for a linux guy, but at the moment I dont know how to handle that.

How can I run a script if a usb device was pluged in?
I have to configure that usb device as network adapter. My script should do this very vell.
But I dont want to run that script in a loop and check every dmesg log.

Is it possible to run a script even a usb device was pluged in? Or is there another way to do that? Do I have to creat a deamon?

thank you :slight_smile:

https://forums.opensuse.org/showthread.php/519495-get-network-interface-name?p=2789475#post2789475

You could create a udev rule for this, so that a script is run or a variable set perhaps.

I tried this now on suse linux enterpise 11 sp4.

And I can’t get any script running with an udev rule.

I’ve created a rule called 80-test.rules in /etc/udev/rules.d
ACTION=“add”, RUN*="/tmp/test.sh"
is the only content in this file.
I want to run a script on every usb add action for all devices.

but nothing happens.
running the script manually works fine.

any idea how to solve this?

thanks

Are you running openSUSE 13.2 or SLES?? These are different animals so may have different solutions

oh sry, I’ve seen that this was my fault. Now I’m trying that on SLES not openSuse anymore.
Acutly I’m trying that on SLES.
Is this not using udev?

N idea this is the openSUSE forum NOT the SUSE forum.

You should read some how to’s first eg
https://wiki.archlinux.org/index.php/udev#Writing_udev_rules
Be careful with your syntax too. It should look like more like

ACTION=="add", RUN+="/tmp/test.sh"