I am trying to read wp usernames and passwords / db names from my script - however I am facing the below issue;
wpconfigs=($(find . -name "wp-config.php"))
for i in "${wpconfigs[@]}"; do
wpdb=$(grep -e "DB_NAME" $i | cut -d \' -f 4)
wpuser=$(grep -e "DB_USER" $i | cut -d \' -f 4)
wppass=$(grep -e "DB_PASS" $i | cut -d \' -f 4)
allpriviledges="ALL PRIVILEGES"
If I echo the results for example if DB name was 12345
I'd get
wpdb=12345
If the username has a special char, for example a $ I get
wpdb='12434$'
The result is showing ''
either side if a special char is found
However, as I am passing the result to a command - the command recieves '123434$'
where a special char is found (wrong) and works where it is 12345
as it says wpdb=12345
rather than wpdb='12345$'
I am passing the results to the below command;
So where it isn't a special char it works fine
uapi --output=jsonpretty --user="$cpuser" Mysql create_user name="${wpuser}" password="${wppass}";