2 added 5 characters in body; edited tags
source | link

I'm working on a script to check the status of several remote MYSQL hosts by logging into the every server and recording weatherwhether the login has been sucesfullsuccessful or not. The idea is to store the login details for the MYSQL hosts in a CSV file and get the script to loop through this file, login and record if login has been sucesfullsuccessfull.

The MYSQL Login data stored in the CSV file would the following:

$host,$user,$password

$host,$user,$password

Being a novice at bash scripting, I'm having trouble understanding on how it's best to approach the part where the script loops through a CSV to obtain MYSQL details. Can anyone help?

Currently I tested the below for individual MYSQL Hosts

mysql -h$host -=$user -p$pass -d$db -e exit
if [ "$?" -eq "0" ]
then
        echo "Connection established"
else
        echo "Connection not established"
fi

Thanks in advance.

I'm working on a script to check the status of several remote MYSQL hosts by logging into the every server and recording weather the login has been sucesfull or not. The idea is to store the login details for the MYSQL hosts in a CSV file and get the script to loop through this file, login and record if login has been sucesfull.

The MYSQL Login data stored in the CSV file would the following:

$host,$user,$password

Being a novice at bash scripting, I'm having trouble understanding on how it's best to approach the part where the script loops through a CSV to obtain MYSQL details. Can anyone help?

Currently I tested the below for individual MYSQL Hosts

mysql -h$host -=$user -p$pass -d$db -e exit
if [ "$?" -eq "0" ]
then
        echo "Connection established"
else
        echo "Connection not established"
fi

Thanks in advance.

I'm working on a script to check the status of several remote MYSQL hosts by logging into the every server and recording whether the login has been successful or not. The idea is to store the login details for the MYSQL hosts in a CSV file and get the script to loop through this file, login and record if login has been successfull.

The MYSQL Login data stored in the CSV file would the following:

$host,$user,$password

Being a novice at bash scripting, I'm having trouble understanding on how it's best to approach the part where the script loops through a CSV to obtain MYSQL details. Can anyone help?

Currently I tested the below for individual MYSQL Hosts

mysql -h$host -=$user -p$pass -d$db -e exit
if [ "$?" -eq "0" ]
then
        echo "Connection established"
else
        echo "Connection not established"
fi

Thanks in advance.

1
source | link

Loop through file to obtain bash script variable

I'm working on a script to check the status of several remote MYSQL hosts by logging into the every server and recording weather the login has been sucesfull or not. The idea is to store the login details for the MYSQL hosts in a CSV file and get the script to loop through this file, login and record if login has been sucesfull.

The MYSQL Login data stored in the CSV file would the following:

$host,$user,$password

Being a novice at bash scripting, I'm having trouble understanding on how it's best to approach the part where the script loops through a CSV to obtain MYSQL details. Can anyone help?

Currently I tested the below for individual MYSQL Hosts

mysql -h$host -=$user -p$pass -d$db -e exit
if [ "$?" -eq "0" ]
then
        echo "Connection established"
else
        echo "Connection not established"
fi

Thanks in advance.