Re: Can AppleScript determine if a shell process is running?
Re: Can AppleScript determine if a shell process is running?
- Subject: Re: Can AppleScript determine if a shell process is running?
- From: Ted Wrigley <email@hidden>
- Date: Sun, 21 Sep 2014 16:16:43 -0700
On Sep 21, 2014, at 1:45 AM, email@hidden wrote:
I'm considering creating a toggle for a couple of shell processes I run occasionally. I would like to be able to start a shell process if it isn't running and shut it down if it is.
So far I'm not even close to solving this. Asking the Finder is getting nowhere.
Thanks J
the ‘pgrep’ utility will return the process id of a running process, so you can use something like this:
try do shell script "pgrep Angband" -- process is running, so do nothing on error -- process is not running, so run it do shell script "/path/to/executable &> /dev/null/ &" end try if the process is launched via a launchd plist you’ll need to modify the script to use launchctl both to test for and launch the process, but the same principle applies. |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden