簡體   English   中英

osx:啟動包含gnu coreutils命令的shell腳本,通過終端而不是通過applescript運行

[英]osx: launching a shell script containing gnu coreutils commands, works via terminal, not via applescript

我已經從osx的macports安裝了gnu coreutils。 當我從終端啟動腳本時,使用各種coreutils的腳本[1]可以按預期工作,但是當使用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

這是什么問題

在外殼程序腳本中設置$PATH以包括實用程序的路徑:

#!/bin/bash
PATH=/opt/local/bin:/opt/local/sbin:$PATH
path_to_open=$(...) && open "${path_to_open}"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM