I am having some trouble getting a do shell script to work. It used to work like a champ, but now seems to return ‘’ instead of the correct results.
Here is the statement that used to work, but now returns ‘’.
obviously the variables are all filled in correctly and the sql looks something like
“select tempate from order where order_id = 11110”
set the_data to (do shell script “/usr/local/mysql/bin/mysql -D " & mysql_db & " -u " & mysql_user & " -p” & mysql_pw & " -h " & mysql_host & " -e "" & sql_query & “"”)
Can anyone help me?
Thanks in advance.
The command itself looks fine to me, so I would try something like this to debug it:
Change the command to this:
return "/usr/local/mysql/bin/mysql -D " & mysql_db & " -u " & mysql_user & " -p" & mysql_pw & " -h " & mysql_host & " -e \"" & sql_query & "\""
This way you will get the actual command that your script is trying to execute, and you can copy&paste it in Terminal. I suppose it gives an empty result set? If yes, that means that the problem is in your SQL query and not really in your script. This should help you to spot the error, as you can narrow the possible reasons for the unexpected behaviour.