# Fixing a 3g dongle serial addresses



## trumee (Jul 22, 2018)

Hello,

I have a 3g dongle which creates cuaU0.0 and  cuaU0.1 entries when it is attached. On re-attaching the device it will make cuaU1.0 and cuaU1.1. I want to make permanent entries for these device nodes. Unfortunately, the following doesnt work,


```
# cat /usr/local/etc/devd/e3372h.conf
#12d1:1506 
attach 20 {
        match "vendor" "0x12d1";
        match "product" "0x1506";
        action "ln -sf /dev/cua$ttyname /dev/controller1";
};

detach 20 {
        device-name "ugen[0-9].[0-9]";
        match "vendor" "0x12d1";
        match "product" "0x1506";
        action "rm -rf /dev/controller1";
};

# ls -la /dev/controller1 
lrwxr-xr-x  1 root  wheel  8 Jul 22 10:34 /dev/controller1 -> /dev/cua
```

How can I have two entries made with devd?


----------



## trumee (Jul 22, 2018)

On the same topic i want to pass an action but devd doesnt like it,


```
$cat /etc/devd/e3372h.conf
#12d1:1506
attach 20 {
        match "vendor" "0x12d1";
        match "product" "0x1506";
        action "echo 'AT^NDISDUP=1,1,"internet"'>/dev/cuaU0.1";
};
```

It fails,

```
$devd -d -f /etc/devd/e3372h.conf
Parsing /etc/devd/e3372h.conf
devd: Cannot parse /etc/devd/e3372h.conf at line 5
```

If i stick the action line in a script, then it works fine:


```
$cat /usr/local/bin/e3372.sh 
#/bin/sh
echo 'AT^NDISDUP=1,1,"internet"' > /dev/cuaU0.1

$cat /etc/devd/e3372h.conf
#12d1:1506
attach 20 {
        match "vendor" "0x12d1";
        match "product" "0x1506";
        action "/usr/local/bin/e3372.sh";        
};
```


----------



## ralphbsz (Jul 23, 2018)

No idea on the first question, it's been too long since I played with devd.

On the second one: Most likely what happens is that the command you give in "line 5" is executed by using fork and exec.  And the ">" sign doesn't work for standalone commands that are being executed, it is part of the shell.  So you need to execute the command using a shell.  The easiest way to do that is to make a very short shell script, as you did.  In theory, you could also use "/bin/sh -c echo ... > ..." as the command, but that's unnecessarily complex.

If there were a version of /bin/echo that allowed command line parameters for where it writes the output to, that would be another option.  For example a hypothetical "echo -o /dev/cuaU0.1 AT...", but the standard echo doesn't take any such parameters.  I think you could do this with a 1-line awk invocation, but now we are getting seriously crazy, and a short shell script is just much easier.


----------

