在Applescript中,如何在ps shell的do shell脚本中传递(或提示)密码?

时间:2015-01-14 19:39:37

标签: shell applescript psql

澄清一点,我不是在谈论我的行政凭据。我特别谈论数据库凭据。

如果我在终端中运行这样的脚本:

/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:没有提供密码”

由于

1 个答案:

答案 0 :(得分:0)

将其添加到shell脚本的开头:'PGPASSWORD = myPassword'