I’m trying to automate the connecting to my uni’s vpn. Here’s what I’ve got:
delay 3
do shell script "/Applications/VPNClient.app/Contents/MacOS/VPNClient -c -user \"matthew\" \"Wireless (free)\""
delay 2 -- [1]
tell application "System Events" to set visible of process "VPNClient" to false -- hide window
Only problem is [1] and below it never execute because the do shell script is left (for lack of a better word) “open”. It connects, but then it just sits there, waiting, leaving the script waiting. How do I run the shell script, and then… “exit” it?
Try appending " &>/dev/null &" to the end of your command string. This should work for most single command invocations.
The first part redirects the ˜stdout’ and ˜stderr’ of the program to /dev/null (a special device that ignores anything written to it).
The last part (the trailing ampersand) tells the shell to run the command in the background.
If use only the first part without the second part, the shell will wait until the VPN client exits (like it does for any other foreground command).
If you use only the second part and not the first the shell will exit after launching the VPN client. But, unless the VPN client closes the ˜stdout’ and ˜stderr’ pipes that do shell script creates, do shell script will end up waiting until the VPN client either closes those pipes or exits/crashes (which implicitly closes them).