通过Automator / Applescript和Terminal运行psql命令

时间:2017-05-17 08:22:34

标签: terminal applescript psql

我在运行以下Applescript时遇到困难,我收到此错误消息Expected “"” but found unknown token.指向"\copy

on run {input, parameters}
    tell application "Terminal"
        activate
        do script with command "psql -h host -d server -U user” in front window
        delay 3
        do script “password” in front window
        delay 3
        do script with command "\copy (SELECT query_to_xml('SELECT jobs.name FROM jobs WHERE jobs.id = 012345’, true, true, '')) TO '/Users/alex/result_sql.xml' " in front window
    end tell
end run

任何人都可以提供帮助或协助吗?我想在Automator-Applescript-Terminal中保留它,以便我的团队中的其他人可以轻松使用它。

谢谢你,Alex

1 个答案:

答案 0 :(得分:0)

......当然,反斜杠'\'就是问题 - 为了让Applescript理解第二个'\'而得到双重'\'。 Technical note on developer.apple.com 谢谢,Alex