1

When you download and extract latest phpMyAdmin, it comes with a config.sample.inc.php file. I would like to set a random blowfish_secret value on this line:

$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

So, what I have tried so far is:

#!/bin/bash
cp config.sample.inc.php config.inc.php;
search="\$cfg['blowfish_secret'] = '';"; 
replace="\$cfg['blowfish_secret'] = '1234';"; 
sed -i -e 's/$search/$replace/g' config.inc.php; 
# debug
echo $search;
echo $replace;
cat config.inc.php;

When I tested this script, the copied config.inc.php file does not appear to have been updated. Any ideas why? the search & replace fields are correctly getting set:

enter image description here

2
  • Thanks to copy/paste and don't use images for the futur Commented Dec 31, 2015 at 14:51
  • Don't use semicolon on bash. Bash don't need semicolon.
    – MaXi32
    Commented Dec 25, 2020 at 23:54

1 Answer 1

1

Try this instead :

sed -i "s/\$cfg\[.blowfish_secret.\]\s*=.*/$replace/" file

If you put single-quotes around variables, the variables can't be expanded

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.