ebarrere Posted July 1, 2013 Share Posted July 1, 2013 Hey all - I'm trying to pass two arguments to a shell script in Alfred (I've tried both v2 and v1) and I can't seem to get any output. The script works fine when run through the terminal, or when "silent" is unchecked in version 1, but there is no output to the Notification Center. I've read the article here, and tried using read to parse the {query} string, but to no avail. Here is the full script, fwiw: read IP NETMASK <<< "{query}" elinks -dump "http://jodies.de/ipcalc?host=${IP}&mask1=${NETMASK}&mask2=" | awk '/^Address:/,/^Hosts/' Any ideas? Link to comment
vitor Posted July 1, 2013 Share Posted July 1, 2013 Did you untick the “Spaces” box on “Escaping”, just above the area where you write your script in Alfred? Link to comment
ebarrere Posted July 1, 2013 Author Share Posted July 1, 2013 Good thought, but I have tried it checked and unchecked in version 1 and 2. Link to comment
vitor Posted July 1, 2013 Share Posted July 1, 2013 I was asking because it seems to be working for me, except if I turn that option on (naturally).Try this, then. Instead of read IP NETMASK <<< "{query}" use something like IP=$(cut -d " " -f1 <(echo "{query}")) NETMASK=$(cut -d " " -f2 <(echo "{query}")) Does it work for you? Link to comment
ebarrere Posted July 1, 2013 Author Share Posted July 1, 2013 Good idea, but parsing the variables that way also doesn't work -- still nothing at all in Notification Center. Link to comment
vitor Posted July 1, 2013 Share Posted July 1, 2013 Could you share the workflow, so we can better evaluate what the problem might be? Link to comment
ebarrere Posted July 2, 2013 Author Share Posted July 2, 2013 Sure, here's a link to the exported workflow. Link to comment
jdfwarrior Posted July 2, 2013 Share Posted July 2, 2013 Sure, here's a link to the exported workflow. I don't have elinks and not sure what the output is supposed to be but could you try capturing the output that you are looking to get from the command in a variable and then echoing that? Also, in the notification center item, set your title and set the text to {query} to grab the text from the previous piece Link to comment
vitor Posted July 2, 2013 Share Posted July 2, 2013 Also, in the notification center item, set your title and set the text to {query} to grab the text from the previous piece That’s what I was thinking could be the problem, when asking to see the workflow. If the script itself is working well, making that small adjustment should make the workflow work. Link to comment
ebarrere Posted July 2, 2013 Author Share Posted July 2, 2013 Thanks for the suggestions. I've changed the script to look like this: IP=$(cut -d " " -f1 <(echo "{query}")) NETMASK=$(cut -d " " -f2 <(echo "{query}")) RETURN=$(elinks -dump "http://jodies.de/ipcalc?host=${IP}&mask1=${NETMASK}&mask2=" | awk '/^Address:/,/^Hosts/') echo ${RETURN} but nothing has changed. I've also added {query} to both the "Title" and "Text" sections of the Post Notification action, but still nothing. Link to comment
ebarrere Posted July 2, 2013 Author Share Posted July 2, 2013 Aha, got it! Apparently elinks wasn't in Alfred's PATH variable. I just added the full path to the elinks executable and it works now. It looks like Alfred doesn't read my .bash_login file, probably because it's not a login shell Anyway, I can poke around and put the PATH variables elsewhere. Thanks for helping lead me to the solution! Link to comment
vitor Posted July 2, 2013 Share Posted July 2, 2013 It looks like Alfred doesn't read my .bash_login file Completely forgot about that. Yes, it’s a common issue, as Alfred does not read those files. A common solution would be to just add to the top of the script source "${HOME}/.bash_login" or PATH="/usr/local/bin:$PATH" (or whatever you need your PATH to be). That way you can keep the rest of your script pretty much intact, without having to always remember to use the full path of the executables. 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