# "No Match" csh script problem



## YtterbiumYAG (Jun 19, 2014)

Hi,

I am trying to write a simple password reading script 


```
#! /bin/csh
echo -n "enter password: "
stty -echo
set pw=$<
stty echo
echo $pw > passphrase
cat passphrase
```

This works but when the password string contains special characters like * and $ it throws an error "No Match". How do I have to modify the script that special characters are set correctly to the variable?

Thank you
YAG


----------



## wblock@ (Jun 19, 2014)

Step 1: do not use csh(1) for scripts.  Good for interactive use, bad for scripts.  Use sh(1).

```
#!/bin/sh
echo -n "enter password:"
stty -echo
read pw
stty echo
echo "entered: $pw"
```

Also, I doubt this is very secure.  dialog(1) has an option to accept passwords, but it may not be that secure, either.


----------



## YtterbiumYAG (Jun 19, 2014)

It is only for mounting a geli encrypted ZFS-Pool on startup, so that I don´t have to type the password 4 times. (I posted only the relevant part of the script.)
As csh() is the standard shell for root in FreeBSD I thought it is a good idea to create the script for csh() and not for sh().
Can I use the read command only with sh()?


----------



## wblock@ (Jun 19, 2014)

builtin(1) says no, read is only for sh(1).  Although it is in /usr/bin/read.

It really does not matter.  sh(1) is present in the base system, and all the system scripts are written in it.  Just because the interactive shell is csh(1) does not mean it has to be used for scripts.  History has shown that it is bad for that.  Please use sh(1).


----------



## YtterbiumYAG (Jun 19, 2014)

Thank you. I will use sh(1) instead.
Here is the full script, maybe it helps someone else as well.

```
#!/bin/sh
echo -n "encryption password: "
stty -echo
read pw 
stty echo
echo
echo $pw > passphrase
geli attach -j passphrase /dev/label/disc1
geli attach -j passphrase /dev/label/disc2
geli attach -j passphrase /dev/label/disc3
geli attach -j passphrase /dev/label/disc4
rm passphrase
zfs mount tank/backup
zfs mount tank/files
zpool status
zfs list
zfs get mounted
```

If there is a way to directly pass the passphrase to geli I would not need to create the passphrase-file on the local drive. But geli(8) says only `-j passfile` und `-k keyfile` are possible.


----------

