xeyr Posted March 29, 2013 Share Posted March 29, 2013 (edited) This one seems a bit strange, but I'll try and explain it clearly... I have a workflow to create or kill an SSH tunnel. With keyword + argument it runs the following script: ssh -f -N -D 1080 {query} -o ServerAliveInterval=15 && echo "Tunnel created" || "Tunnel failed to start" If I run this in terminal (replacing query with the relevant details), the "Tunnel created" text is displayed immediately, as SSH is run and sent immediately to the background. If I run this workflow in Alfred, the notification does not display until the SSH process terminates (by manually `kill`ing the PID). Obviously I consider the terminal behaviour correct, as the script is "finished" once SSH is launched in the background, and the success is echoed out immediately (while SSH runs in the background). Alfred v2.0.2 (178) OS X 10.8.3 Edited March 29, 2013 by xeyr Link to comment
Andrew Posted March 29, 2013 Share Posted March 29, 2013 This one seems a bit strange, but I'll try and explain it clearly... Alfred v2.0.2 (178) OS X 10.8.3 Alfred uses NSTasks to run scripts in the background and these by nature will not 'finish' until all tasks and subtasks are completed. You will need to completely hand off creating the tunnel so it's not considered a subtask. I've been looking around the forum as I know a few people (I think Tyler Eich, I've just messaged him) have done this before (by piping into dev/null etc) but I can't seem to find it at the moment, so I've moved this into Workflow questions so that somebody else can help you out Link to comment
Tyler Eich Posted March 29, 2013 Share Posted March 29, 2013 Alfred uses NSTasks to run scripts in the background and these by nature will not 'finish' until all tasks and subtasks are completed. You will need to completely hand off creating the tunnel so it's not considered a subtask. I've been looking around the forum as I know a few people (I think Tyler Eich, I've just messaged him) have done this before (by piping into dev/null etc) but I can't seem to find it at the moment, so I've moved this into Workflow questions so that somebody else can help you out I can't remember ever doing this (I'm terrible at bash scripting ), but CarlosNZ did. He used this code: ./myscript.sh > /dev/null 2>&1 & Here's the original post: http://www.alfredforum.com/topic/656-alfred-waits-on-script-child-processes/ Link to comment
Andrew Posted March 29, 2013 Share Posted March 29, 2013 I can't remember ever doing this (I'm terrible at bash scripting ), but CarlosNZ did. He used this code: ./myscript.sh > /dev/null 2>&1 & Here's the original post: http://www.alfredforum.com/topic/656-alfred-waits-on-script-child-processes/ Oops! Thanks for helping out though, appreciated Tyler Eich 1 Link to comment
xeyr Posted March 29, 2013 Author Share Posted March 29, 2013 Great, thanks the pointers and links 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