Do you realy need double quotes? If you’re using single quotes you can use ‘quoted form of’ like this
set theString to "I'm containing a quote"
do shell script "echo " & theString --result in a error
do shell script "echo " & quoted form of theString -- will return theString
Also I have a MySQL Script object that could be usefull…
Also when no ssh certificates are installed (need password) you could use this code as well
set sshUser to "sshuser"
set sshPasswd to "sshpasswd"
set sshServer to "server"
set externalCommand to "/usr/local/mysql/bin/mysql -u mysqluser -pmysqlpasswd -e 'show databases'"
set thecommand to "(echo \"spawn ssh"
set thecommand to thecommand & " " & sshUser & "@" & sshServer
set thecommand to thecommand & " " & externalCommand & "\" ;"
set thecommand to thecommand & "echo \"expect {\" ;"
set thecommand to thecommand & "echo \"\\\"Password:\\\" {send \\\""
set thecommand to thecommand & sshPasswd
set thecommand to thecommand & "\\\\r\\\" ; exp_continue }\" ;"
set thecommand to thecommand & "echo \"\\\"yes/no?\\\" {send \\\"yes\\\\r\\\" ; exp_continue }\" ;"
set thecommand to thecommand & "echo \"eof\" ;"
set thecommand to thecommand & "echo \"}\" ;"
set thecommand to thecommand & ") | expect"
do shell script thecommand