1
爲了澄清,我不是在談論我的管理憑證。我特別談論數據庫憑證。在Applescript中,如何在psql的shell腳本中傳遞(或提示)密碼?
如果我在終端運行此腳本是這樣的:
/usr/local/bin/psql -h my-db -U userName test -Atc 'SELECT id, title, internal_name FROM my.template WHERE my_id = 5'
...它工作正常。
但在AppleScript的:
set myInfo to do shell script ("/usr/local/bin/psql -h my-db -U userName test -Atc 'SELECT id, title, internal_name FROM my.template WHERE my_id = 5'")
...它吐出 「PSQL:fe_sendauth:未提供口令」
感謝
當您在終端中運行psql命令時,它是否提示您輸入pw?你是否檢查過手冊頁來查看包含密碼的語法? – jweaks
是的,它在終端中運行時會提示輸入密碼。在Applescript中,腳本會失敗,並顯示'沒有提供密碼'的錯誤。我聽說可以使用〜/ .pgpass,但我不確定如何在applescript中傳遞 – thizzle
如果您在手冊頁中找到傳遞pw的語法,我們可以在AS中找到它。 – jweaks