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 (the oldpass string is replaced with nothing):
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. I must admit i'm not totally sure how the password is being generated. If it helps to clarify what the issue might be, this script is contained within a postwwwact cPanel script
can anyone see what the issue might be?