# How to get the port number of a USB stick



## rayit (Jun 22, 2012)

For a project I need to copy a file to a USB stick. I need to know the port which a USB stick is connected to. I can not use PID or VID for this, the USB sticks change. With *dmesg* I do not see the port, camcontrol, cdrecord, usbconfig also gives no port.

If I disconnect the USB stick I get the port!!!!.

```
umass0: at uhub4, [B]port 3[/B], addr 3(disconnected)
```

This port number I need, th*e*n I can program something that if I instruct a person to put 
a USB stick to a certain port it will copy one file and if a USB stick is put into the other port it will copy another file.

Many thanks
Raymond


----------



## wblock@ (Jun 22, 2012)

devd(8) is made just for detecting and reacting to dynamic device changes.  The properties of the device are available through variables.


----------



## rayit (Jun 22, 2012)

Hello wblock@, I looked into devd but can not see how this will help me? How to get those variables? I want to see which port a USB is attached to.

*M*any thanks,
Raymond


----------



## wblock@ (Jun 22, 2012)

Look at devd.conf(5) and /etc/devd.conf itself.


----------

