Hi I am pretty new to this so please forgive any stupidity.
I have made a simple script to run synergy which is a server and client program to use one keyboard and mouse over multiple computers.
It is an awesome program!!
The script works except it remains active and in the dock after it has executed the commands.
on run
do shell script "/Applications/synergy-1.3.2/synergys -f --config /Applications/synergy-1.3.2/synergy.conf "
end run
So I want this application to quit.
I do not want to quit synergy.
How can I quit the app as part of its own process?
i tried ‘quit’ and tried to get it to run another script that tries to close this app but to no avail.
I can now only quit it with force quit.
My mac does not shut down unless I have quit the app.
Thanks
I think this is your problem. AppleScript’s do shell script holds the process’ stdout and stderr hooks waiting for the output of the command. That’s why it appears to hang - it’s doing what it’s designed to do… it’s waiting for synergys to finish.
The solution is simple - you redirect stderr and stdout to some other location and send the shell process to the background
the > /dev/null redirects the process’ stdout to /dev/null (you can use some other file path if you want to capture its output). 2>&1 redirects stderr to the same place as stdout (in this case, /dev/null) and the trailing & sends the process to the background.
You’ll find that this effectively returns control back to your script while the shell process runs in the background
on run
do shell script "/Applications/synergy-1.3.2/synergys -f --config /Applications/synergy-1.3.2/synergy.conf > /dev/null 2>&1 &"
end run
sorry but that is all gubbledigoob to me.
could you please send me some code.
and will this quit the script?
I did give you the code. Note the " > /dev/null 2>&1 &" on the end of your code. It will allow the script to continue, which in your case since it’s the end of the script then the script will automatically quit.
sorry bout that did not look straight.
Thanks heaps.
It all works like a charm.
Can you recommend anything to learn this scripting better?
Books or resources or manuals on the net?
Thanks
I’m glad it worked. 
There are many tutorials on this website. Go to the front page http://macscripter.net/ and then look at the sections in the upper right part of the front page. The unscripted section has many tutorials as well as some of the other section. There’s some tutorials called something like “applescript for beginners” that you can find in the unscripted section.
Regarding the tutorials…
if you go to the front page http://macscripter.net/ and do a search in the “Search Articles” box the tutorials I mentioned will come right up. Search for “applescript tutorial for beginners” (include the quotes in the search box). You’ll see there’s 9 lessons, so start at the beginning and go through them. That’s how I learned anyway.
After you learn the basics go to the unscripted section to find other tutorials.