myvar=$(mysql mydatabase -u $user -p$password -se "SELECT a, b, c FROM table_a") ---------------------------------- mytmp=$(mktemp /tmp/mytemp.XXXXXX) mysql --host=localhost --user=ordercgm_ordercgm --password=12Sret05#* -e "SELECT id FROM ordercgm_ordercgm.data_full WHERE table_name='rx_request' LIMIT 5 \G;" > $mytmp column_foo=$( fgrep id $mytmp | cut -d ':' -f2-) echo $column_foo php /home/ordercgm/public_html/tcPDF/efaxTest2.php -COLUMN_FOO id -------------------------------------- #Fix the LIMIT 5 of SELECT STATEMENT #This will get all ids from data_full table where table_name =rx_request mapfile result < <(mysql --host=localhost --user=ordercgm_ordercgm --password=12Sret05#* -e "SELECT id FROM ordercgm_ordercgm.data_full WHERE table_name='rx_request' LIMIT 5") #Do a for loop and loop through every id and send a fax for row in "${result[@]}";do php /home/ordercgm/public_html/portal/tcPDF/fax_create/echoArg.php ${row%$'\t'*} done #Use this when doing site_id so can pass to php file and only perform a certain item based on fax #pass below would be the site_id, must update the sql query and php code https://stackoverflow.com/questions/35274597/store-mysql-result-in-a-bash-array-variable for row in "${result[@]}";do echo Name: ${row%$'\t'*} pass: ${row#*$'\t'} done