我在osx上安装了来自macports的gnu coreutils。这个脚本[1],使用各种coreutils,当我从终端启动它时按预期工作,但是当我使用applescript [2]启动它时,我收到一条错误消息[3]。
[1] Shell脚本:
#!/bin/bash
path_to_open=$(gfind | grep -v "~$" | grep -v "#$" | gshuf | ghead -n 1) && open "${path_to_open}"
[2] Applescript:
do shell script "sh ~/x/scripts/script1.sh"
[3]错误讯息:
error "[script_path]: line 2: gfind: command not found
[script_path]: line 2: gshuf: command not found
[script_path]: line 2: ghead: command not found" number 127
这里有什么问题?
答案 0 :(得分:0)
在shell脚本中设置$PATH
以包含实用程序的路径:
#!/bin/bash
PATH=/opt/local/bin:/opt/local/sbin:$PATH
path_to_open=$(...) && open "${path_to_open}"