This is my automation script, the commands work fine when I run them from Terminal.
Best Answer
The PATH passed to a Run Shell Scriptaction in Automator by default is:
/usr/bin:/bin:/usr/sbin:/sbin
You need to include a PATHstatement in the Run Shell Scriptaction and or use fully qualified pathnames for any executables called.
That said, using three separate Run Shell Scriptactions in this use case makes the first one useless as change directory in the first Run Shell Scriptaction has absolutely no bearing on the subsequent Run Shell Scriptactions. You should work all the commands into a single Run Shell Scriptaction.
In a single Run Shell Scriptaction you could use the following example shell scriptcode:
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:
cd "$HOME" || exit
brew update && brew upgrade
As coded, it does the following:
The PATHstatement includes /usr/local/bin where I'd assume brew is.
If the cdcommand fails the script is stopped.
brew upgrade is only executed if brew update succeeds .
That all said, I would just use Terminal normally to perform any brewcommands so as to be able to see what is going on.
This is weird, but I have seen at least three people on Apple Support Communities who had this problem when a of process "x" and a tell application "System Events" to are on the same line.
Try this.
on run {input, parameters}
tell application "System Events"
tell process "TextWrangler" to set visible to not visible
end tell
end run
Running it in an apple script is not that bad. you just have to run the entire script as root because sudo requires user interaction. if you do an apple script like this one:
do shell script "cd ~/Desktop/PopcornTV && /path/to/npm install && /path/to/node atv.js" with administrator privileges
replace then/path/to/npm and /path/to/node with the output of which npm and which node
it will open up a dialogue and ask you for your password.
Best Answer
The
PATH
passed to a Run Shell Script action in Automator by default is:You need to include a
PATH
statement in the Run Shell Script action and or use fully qualified pathnames for any executables called.That said, using three separate Run Shell Script actions in this use case makes the first one useless as change directory in the first Run Shell Script action has absolutely no bearing on the subsequent Run Shell Script actions. You should work all the commands into a single Run Shell Script action.
In a single Run Shell Script action you could use the following example shell script code:
As coded, it does the following:
PATH
statement includes/usr/local/bin
where I'd assumebrew
is.cd
command fails the script is stopped.brew upgrade
is only executed ifbrew update
succeeds .That all said, I would just use Terminal normally to perform any
brew
commands so as to be able to see what is going on.