URL:     https://linuxfr.org/forums/linux-general/posts/executer-un-script-a-la-d%C3%A9connexion-dun-p%C3%A9riph%C3%A9rique
Title:   executer un script a la déconnexion d'un périphérique
Authors: Toto
Date:    2008-10-13T00:48:55+02:00
Tags:    
Score:   1


Bonjour,  
  
Je souhaiterais pouvoir executer un script lorsque je déconnecte ma clé usb. J'ai regardé du coté du udev mais il ne prend pas en compte l'action "remove", alors que la création fonctionne parfaitement. J'ai aussi regardé du coté de hotplug, et la, j'ai l'impression d'avoir mis ce qu'il fallait, mais toujours le néant.  
Si quelqu'un avait une idée ou correction, ca serait super !  
  
Distrib : Gentoo  
regle udev :  
      
    $ cat /etc/udev/rules.d/10-local.rules  
    KERNEL=="sd*", SUBSYSTEMS=="usb", ATTRS{manufacturer}=="Intuix", ATTRS{product}=="DiskOnKey", ATTRS{serial}=="0991376121B17936",  GROUP="hal", MODE="640", RUN+="/usr/local/sbin/myscript"  
  
  
Mon script :  
      
    #!/bin/bash  
    echo "___$ACTION" >> /test  
  
  
Et je ne vois apparaitre que des ___add, rien d'autre.  
Ma règle hotplug (fichier /etc/hotplug/usb.usermap)  
      
    myscript      0x0000      0x08ec   0x0020    0x0000       0x0002       0x0000       0x0000          0x0000          0x0008          0x0006             0x0050             0x00000000  
  
  
Et mon lsusb -vv au cas ou il y aurait une erreur  
      
    Bus 001 Device 023: ID 08ec:0020 M-Systems Flash Disk Pioneers  
    Device Descriptor:  
    £spaces£  £/spaces£bLength                18  
    £spaces£  £/spaces£bDescriptorType         1  
    £spaces£  £/spaces£bcdUSB               2.00  
    £spaces£  £/spaces£bDeviceClass            0 (Defined at Interface level)  
    £spaces£  £/spaces£bDeviceSubClass         0  
    £spaces£  £/spaces£bDeviceProtocol         0  
    £spaces£  £/spaces£bMaxPacketSize0        64  
    £spaces£  £/spaces£idVendor           0x08ec M-Systems Flash Disk Pioneers  
    £spaces£  £/spaces£idProduct          0x0020  
    £spaces£  £/spaces£bcdDevice            2.00  
    £spaces£  £/spaces£iManufacturer           1 Intuix  
    £spaces£  £/spaces£iProduct                2 DiskOnKey  
    £spaces£  £/spaces£iSerial                 3 0991376121B17936  
    £spaces£  £/spaces£bNumConfigurations      1  
    £spaces£  £/spaces£Configuration Descriptor:  
    £spaces£    £/spaces£bLength                 9  
    £spaces£    £/spaces£bDescriptorType         2  
    £spaces£    £/spaces£wTotalLength           32  
    £spaces£    £/spaces£bNumInterfaces          1  
    £spaces£    £/spaces£bConfigurationValue     1  
    £spaces£    £/spaces£iConfiguration          0  
    £spaces£    £/spaces£bmAttributes         0x80  
    £spaces£      £/spaces£(Bus Powered)  
    £spaces£    £/spaces£MaxPower               94mA  
    £spaces£    £/spaces£Interface Descriptor:  
    £spaces£      £/spaces£bLength                 9  
    £spaces£      £/spaces£bDescriptorType         4  
    £spaces£      £/spaces£bInterfaceNumber        0  
    £spaces£      £/spaces£bAlternateSetting       0  
    £spaces£      £/spaces£bNumEndpoints           2  
    £spaces£      £/spaces£bInterfaceClass         8 Mass Storage  
    £spaces£      £/spaces£bInterfaceSubClass      6 SCSI  
    £spaces£      £/spaces£bInterfaceProtocol     80 Bulk (Zip)  
    £spaces£      £/spaces£iInterface              0  
    £spaces£      £/spaces£Endpoint Descriptor:  
    £spaces£        £/spaces£bLength                 7  
    £spaces£        £/spaces£bDescriptorType         5  
    £spaces£        £/spaces£bEndpointAddress     0x81  EP 1 IN  
    £spaces£        £/spaces£bmAttributes            2  
    £spaces£          £/spaces£Transfer Type            Bulk  
    £spaces£          £/spaces£Synch Type               None  
    £spaces£          £/spaces£Usage Type               Data  
    £spaces£        £/spaces£wMaxPacketSize     0x0200  1x 512 bytes  
    £spaces£        £/spaces£bInterval               0  
    £spaces£      £/spaces£Endpoint Descriptor:  
    £spaces£        £/spaces£bLength                 7  
    £spaces£        £/spaces£bDescriptorType         5  
    £spaces£        £/spaces£bEndpointAddress     0x02  EP 2 OUT  
    £spaces£        £/spaces£bmAttributes            2  
    £spaces£          £/spaces£Transfer Type            Bulk  
    £spaces£          £/spaces£Synch Type               None  
    £spaces£          £/spaces£Usage Type               Data  
    £spaces£        £/spaces£wMaxPacketSize     0x0200  1x 512 bytes  
    £spaces£        £/spaces£bInterval               0  
    Device Qualifier (for other device speed):  
    £spaces£  £/spaces£bLength                10  
    £spaces£  £/spaces£bDescriptorType         6  
    £spaces£  £/spaces£bcdUSB               2.00  
    £spaces£  £/spaces£bDeviceClass            0 (Defined at Interface level)  
    £spaces£  £/spaces£bDeviceSubClass         0  
    £spaces£  £/spaces£bDeviceProtocol         0  
    £spaces£  £/spaces£bMaxPacketSize0        64  
    £spaces£  £/spaces£bNumConfigurations      1  
    Device Status:     0x0000  
    £spaces£  £/spaces£(Bus Powered)  
  
  
Et j'ai fait un lien entre myscript de udev et celui de hotplug (mis dans /etc/hotplug/usb/myscript)  
  
  
Merci pour toute aide
