I'm working on a script that takes commands from MySQL and executes them one by one. My problem is I can't execute the commands from script:
./bash.sh: line 26: /myscript.sh -c "": no such file or directory
Line 26 is the command I wish to execute ("$com"). if i try to run the command manually, by echoing the content of "$com" and than run it from terminal, it's working.
What am I doing wrong?
if [ ! "${#array[*]}" -eq "0" ]; then
for (( i=0 ; i<cnt ; i++ )); do
id=$(echo "${array[$i]}" | sed 's@\t@^@g' | cut -f'1' -d'^')
com=$(echo "${array[$i]}" | sed 's@\t@^@g' | cut -f'2' -d'^')
imp=$(echo "${array[$i]}" | sed 's@\t@^@g' | cut -f'3' -d'^')
if [[ "$id" = [0-9]* ]]; then
"$com"
echo "DELETE FROM list WHERE id='$id'" | mysql "$DB_USER" -u "$DB_USER" -p"$DB_PASS"
fi
done
else
echo "The list is empty"
fi
arrayin the first place. Consider maintaining a collection of parallel arrays, i.e.cmd[$i]would contain the command to execute,id[$i]the ID,imp[$i]the value forimp.