Jump to content

Updated to OS X 10.11 El Capitan - Script not working now


Recommended Posts

Hi all - I just upgraded from Yosemite to El Capitan, and now my favorite script isn't working with Alfred 2.8 .  It runs off of a keyword, which is "r". 

 

I'm using the "Run Script Action" but the input script isn't running in terminal.  I have tried the script in terminal, and it works fine, it is "ru {query}".   I thought maybe it could have to do with the new System Integrity Protection that comes with the new OS.  

 

Any ideas as to why this might be?  

Link to post

'ru' isn't a built-in command. If it was installed to one of the system library directories (/bin, /sbin, /usr/bin), then El Capitan moved it during install. You can find it in the migration directory (/Library/SystemMigration/History/Migration-(some UUID)/QuarantineRoot/). The Migration-(some UUID) directory will look something like this - Migration-6D079FB8-BCC2-4A28-B987-1FA2FE3ADE6.

 

Move the 'ru' command into some safe location (/usr/local/bin, ~/bin, etc.) and make sure that the bin directory you chose is part of your PATH. Even if it's not, the workflow can still work, just provide the full path to the relocated 'ru' command.

Link to post

Ctwise thank you! 

 

I do have a question - I did a fresh install of El Capitan, from a formatted drive, then installed RU.  The RU command works properly from terminal.  It even works in Alfred when it is set up with the "Terminal Command" action as opposed to the "Run Script" action.  The problem is it leaves the terminal window open.  

 

With that said - should I still follow your suggestion? QUICK EDIT - I just discovered that the RU program is included in this directory: /usr/local/bin

 

Does that change anything?  

 

Here is what the set up looks like with "Terminal Command": 0ZXJMLz.png

 

Thanks! 

Edited by olen83
Link to post

Update!  I got it working with the addition of this line: PATH=/usr/local/bin:$PATH

 

The script shows as PATH=/usr/local/bin:$PATH ru {query}

 

Was able to figure it out with between your help ctwise and this post: http://www.alfredforum.com/topic/6199-how-to-run-script-from-usrlocalbin/

 

Thank you very much! 

 

Here is what it looks like now: 

 

TI0Klg3.png

Edited by olen83
Link to post

Escaping tells Alfred which characters need to be escaped, i.e. preceded with a backslash. Alfred's defaults for any given language are correct (but don't change the quotes around {query}!)
 
When it replaces {query}, Alfred basically rewrites your script before running it.
 
If there's something in {query} that would break the script or command or make it invalid, it needs to be escaped. If you have this script to copy a file to your desktop:

cp {query} ~/Desktop

 and the provided input is Some File.txt, Alfred will replace {query} with it and run:

cp Some File.txt ~/Desktop

 which will break because this command says "copy Some and File.txt to ~/Desktop" (the space delimits arguments).
 
As a result, you instead use "{query}" (in quotes), so Alfred runs:

cp "Some File.txt" ~/Desktop

which is correct.
 
In turn, this would break if {query} contained a double quote, e.g. Say, "hello!", as Alfred would expand "{query}" to "Say, "hello!"", closing the quotes and inserting the literal hello!, which the program would interpret as a command or variable, and break.

So, you escape Double Quotes and Alfred instead expands "{query}" to "Say, \"hello!\"", which is once again a valid string.
 
Finally, some languages do some extra processing of strings in double quotes. Certain escapes, like \n and \t, are expanded to newline and tab respectively. So you need to also escape Backslashes to prevent \n becoming a newline. Also, some languages, like PHP and bash, try to expand variables in double-quoted strings, e.g. in echo "Dear $name", they will replace the variable $name with its value (or nothing), so you need to escape Dollar, too.

 

This kind of input may seem odd, but it's common enough for, say, a search engine workflow.
 
If you just want to pass the user's query to your script, you should stick with the defaults for the language you're using. The only other meaningful configuration is escaping off, so you can compose your own commands in {query}. Anything other than defaults or off is probably broken in some way.

Link to post

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...