[Dev] constructing a USB media upload and download device

Quiliro Ordóñez quiliro at congresolibre.org
Mon Oct 15 18:41:21 GMT 2012

I have successfully used devmon for automatically mounting a USB memory, 
copying a directory to it and then unmounting it. It works correctly as 
root user with the following command:
devmon --exec-on-drive "cp -r /home/quiliro/media %d ; umount %d"
I would like devmon to do that on a specific USB port. On another 
specific port, I would like to do the opposite copy operation:
devmon --exec-on-drive "cp -r %d/media /home/quiliro/ ; umount %d"
I understand that can be done by adding a udev rule. I found the 
specifications of the ports by using:
udevadm info -a -p $(udevadm info -q path -n /dev/sdb1)
after plugging in any USB memory to both ports:
KERNELS=="2-1" for the right USB port
KERNELS=="2-2" for the left USB port
The point is not to recognize a USB memory specific product id or device 
id, but to recognize the specific port it was connected to.

So I suppose I need to create a udev rule. I think I have to assign a 
symlink to the USB memories connected to the left port and another to 
the right port. Then, I should use these commands:
devmon --exec-on-device /dev/right_USB "cp -r /home/quiliro/media %d ; 
umount %d"
devmon --exec-on-device /dev/right_USB "cp -r %d/media /home/quiliro/ ; 
umount %d"

Please suggest the rule I should use and the appropiate devmon command. 
If no one is able to answer this question, please guide me to a udev 
rule forum. Thank you.

Saludos libres,

Quiliro Ordóñez
Board Member
Free software FoundationLatiin America
Asociación de Software Libre del Ecuador - ASLE
Av de la Prensa N58-219 y Cristóbal Vaca de Castro
Quito, Ecuador
(593)8-454 8078 (desactivado temporalmente por viaje)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.parabola.nu/pipermail/dev/attachments/20121015/6a5dcff2/attachment.htm>

More information about the Dev mailing list