The problem here is that you're trying to read an input stream with cat /dev/random
, which by itself will never terminate (same thing as trying to do cat /dev/stdin
for example). You can fix it by doing something like
#!/bin/bash
tmp_pass=0
if [ $tmp_pass = 0 ]; then
tmp_pass=`head -c 10 /dev/random | base64`
echo "${tmp_pass:0:10}" #cut to 10 characters after base64 conversion
fi