Random password variable disappears
- by snaken
Hi,
I'm using the following to generate a random password in a shell script:
DBPASS=</dev/urandom tr -dc A-Za-z0-9| (head -c $1 > /dev/null 2>&1 || head -c 8)
When i run this in a file on its own like this:
#!/bin/sh
DBPASS=</dev/urandom tr -dc A-Za-z0-9| (head -c $1 > /dev/null 2>&1 || head -c 8)
echo $DBPASS
A password is echoed. When i incorporate it into a larger script though the variable never seems to get created for some reason,
so for example this doesn't work:
DBPASS=</dev/urandom tr -dc A-Za-z0-9| (head -c $1 > /dev/null 2>&1 || head -c 8)
sed -i s/oldpass/$DBPASS/ mysql_connect.php
If i manually set the variable though everything is fine..
can anyone see why?