how can i get the database name from a config file
its like this:
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'userabc_wrdp1');
(there might be spaces in the front of "define")
i want to store the database name to a variable
$dbname=
thanks!
---------- Post updated at 04:33 AM ---------- Previous update was at 04:06 AM ----------
i tried this but it doesnt work
dbname=`grep '^define.*DB_NAME' $theconfigfile | cut -d "'" -f4`
its giving output like
grep: That's: No such file or directory
grep: all,: No such file or directory
grep: stop: No such file or directory
grep: editing!: No such file or directory
grep: Happy: No such file or directory
grep: blogging.: No such file or directory
: No such file or directory
: No such file or directory
grep: WordPress: No such file or directory
grep: absolute: No such file or directory
grep: path: No such file or directory
---------- Post updated at 04:46 AM ---------- Previous update was at 04:33 AM ----------
i tried:
grep "^ *define.*DB_NAME" grep "^ *define.*DB_NAME" $FILE | cut -d "'" -f4
it works on the command line but not in the shell script
im not sure the syntax
---------- Post updated at 04:54 AM ---------- Previous update was at 04:46 AM ----------
i was using the wrong config file
i got it to work
like
dbname=`grep "^ *define.*DB_NAME" $configfile | cut -d "'" -f4`