I am trying to access variables from a PHP script to a shell script with following codes but I keep getting this error '@'localhost' (using password: YES)or user 'test_user Can anyone please help me?
<?php
$DATABASE='test_db';
$DB_HOST='localhost';
$PASSWORD='test_pw';
$USER='test_user';
?>
#! /bin/bash
DB_FILE_NAME="$BASE_DIR_PATH$DB_PHP_FILE"
DB=$(cat $DB_FILE_NAME | grep "^\$DATABASE=" | cut -d "=" -f 2-)
DB_NAME=$(sed "s/[\;'']//g" <<< "$DB")
USER=$(cat $DB_FILE_NAME | grep "^\$USER=" | cut -d "=" -f 2-)
DB_USERNAME=$(sed "s/[\;'']//g" <<< "$USER")
PASSWORD=$(cat $DB_FILE_NAME | grep "^\$PASSWORD=" | cut -d "=" -f 2-)
DB_PASSWORD=$(sed "s/[\;'']//g" <<< "$PASSWORD")
results=($(mysql --user $DB_USERNAME -p${DB_PASSWORD} ${DB_NAME} -Bse
"SELECT a,b,c from test WHERE profile_name='prop'"))
if [ $? -ne 0 ]; #check if database connection is failed
then
exit
fi