Jump to content

Get absolute path of a command in a workflow


Recommended Posts

Hi,

 

I'm actually finishing my upcoming qrencode workflow which show qrcode image which are generated offline (without the help of the google charts api).

 

For this I rely on "qrencode" which can be installed through homebrew.

 

What I didn't understand is, that the workflow didn't know "qrencode" if I call it without the absolute path to it. This is only within alfred workflow. In a typical shell script it work (outside of Alfred).

 

Therefore I try to get the full path to the binary with:

bin=$(`type -p qrencode`)

to call it afterwards with

$bin <commandoptions>

The debug informations show me only "[ERROR: alfred.workflow.action.script] /bin/bash: line 5: -o: command not found"

 

 

 

Do anybody have some tipps for me to get this working?

 

thx

Link to comment

You might be double-executing the command:

bin=$(`type -p qrencode`)

Just try 

bin=$(type -p qrencode)

The $(cmd) creates a subshell that runs the command and returns the text.

 

Another possibility would be that Alfred loads a neutral shell (this isn't the right term), but that means it doesn't load your .bashrc or .bash_profile files.

 

Instead, you could do something like:

if [[ ! -f /usr/local/bin/qrencode ]]; then
   # Do whatever failure you need to here because the program isn't installed
   exit 1
fi

because thats where Homebrew puts everything.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...