• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Can AppleScript determine if a shell process is running?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Prev by Date: Search Contacts for phone number
  • Next by Date: Re: Search Contacts for phone number
  • Previous by thread: Re: Can AppleScript determine if a shell process is running?
  • Next by thread: Mail ; Compose and Paste Salutation String
  • Index(es):
    • Date
    • Thread