Closed reteps closed 7 years ago
When I run it from the terminal, it works fine! whats up?
Your environment isn't loaded. You need to run your script using /bin/bash -c ...
or /usr/bin/sudo -u you -i a-script.sh
.
More info can be found here https://github.com/oleander/bitbar/commit/9792c95805d1abc97d4afc2cdbbc460fc7a66539#commitcomment-22144737
what is the ...
? the script?
Yes.
hmm. still isn't working.
/bin/bash -c echo -n "E:"; curl -s "https://api.gdax.com/products/ETH-USD/ticker" | jq -r '.bid'
same "jq" not found error"
Bash requires a couple of extra params to work, sudo
with the -i
flag as shown above would be easier.
but then would I need a seperate file to run myscript.sh
?
Thanks for helping!!!
Aha, I missed your |
. Try this /usr/bin/sudo -u you -i bash -c 'echo -n "E:"; curl -s "https://api.gdax.com/products/ETH-USD/ticker" | jq -r ".bid"'
perfect, thanks!
Aha, I missed your
|
. Try this/usr/bin/sudo -u you -i bash -c 'echo -n "E:"; curl -s "https://api.gdax.com/products/ETH-USD/ticker" | jq -r ".bid"'
Bruv you a lifesaver
Provide the absolute path to jq
:
which -a jq
will show something like e.g.:
>>> /usr/local/bin/jq
Now instead of jq -r ".bid"'
use /usr/local/bin/jq -r ".bid"
Because xbar/bitbar does not use your user's $PATH
environment, and instead uses a restricted env that does not include /usr/local/bin
in the $PATH
(similar to the env crontab
uses). If you do want to use your user's environment then do it explicitly at the top of the script with source ~/.bashrc
(if using bash) or source ~/.zshrc
(if using zsh) — but be aware that this might slow down your scripts depending on what you have in your shell config files. A better, safer and faster alternative would be to put at the top of your script
export PATH=/usr/local/bin:$PATH
/usr/local/bin/jq...
Thank you! Pointing directly to the location of it fixed my issue.
Provide the absolute path to
jq
:
which -a jq
will show something like e.g.:>>> /usr/local/bin/jq
Now instead of
jq -r ".bid"'
use/usr/local/bin/jq -r ".bid"
Why should I use an absolute path?
Because xbar/bitbar does not use your user's
$PATH
environment, and instead uses a restricted env that does not include/usr/local/bin
in the$PATH
(similar to the envcrontab
uses). If you do want to use your user's environment then do it explicitly at the top of the script withsource ~/.bashrc
(if using bash) orsource ~/.zshrc
(if using zsh) — but be aware that this might slow down your scripts depending on what you have in your shell config files. A better, safer and faster alternative would be to put at the top of your scriptexport PATH=/usr/local/bin:$PATH
you are a lifesaver!
Folks, Can anyone help how to fix this one? In the GitLab pipeline, I'm getting this issue. However, in terminal jq working perfectly.
my code: