for i in "${cmd_array[@]}"
do
${i} >> $logFile
done
THe variable cmd_array has many elements . One of the element is a mysql command.
It is defined as :
cmd_array[1]='mysql -uroot -prootDB -e "show full processlist" | grep Query | grep -v "show full processlist'
THis command fails to run. When i executed the script using "sh -x " , i am able to see his command is being executed as
mysql -uroot -prootDB -e '"show' full 'processlist"' '|' grep Query '|' grep -v '"show' full processlist
LIMITATION: I can't handle this command separately inside the for loop, as it is a generic code. How do i form the mysql query so that it gets executed.
I have another command [default command] which has no issues:
cmd_array=('cat /proc/${process_pid}/status')
Thanks it worked. THere was no need to have the eval inside for loop.