olen83 Posted October 18, 2015 Share Posted October 18, 2015 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 comment
deanishe Posted October 18, 2015 Share Posted October 18, 2015 It's almost impossible to say without the code and the input/output that's causing the problem. Link to comment
olen83 Posted October 18, 2015 Author Share Posted October 18, 2015 I've uploaded screen shots here which hopefully makes it more clear. The "ru" script works from terminal, just not as an action in Alfred. Link to comment
ctwise Posted October 18, 2015 Share Posted October 18, 2015 '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 comment
olen83 Posted October 18, 2015 Author Share Posted October 18, 2015 (edited) 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": Thanks! Edited October 18, 2015 by olen83 Link to comment
olen83 Posted October 18, 2015 Author Share Posted October 18, 2015 (edited) 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: Edited October 18, 2015 by olen83 Link to comment
deanishe Posted October 19, 2015 Share Posted October 19, 2015 You can just use /usr/local/bin/ru {query}Is there a reason you aren't using the default settings and escaping options? Link to comment
olen83 Posted October 20, 2015 Author Share Posted October 20, 2015 Nice thanks - updated to that. RE default & escaping options, I just set it to as it was originally in the workflow I used in Yosemite. But truthfully, I don't really understand the function of the escaping options. Link to comment
deanishe Posted October 20, 2015 Share Posted October 20, 2015 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. Colin 1 Link to comment
olen83 Posted October 22, 2015 Author Share Posted October 22, 2015 Thank you so much deanishe. So cool that you would explain all that, I really appreciated the lesson. Thanks again! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now