On 2005–10–12, at 23:37, Ted Zeng wrote:
I would like to find out if an application like Illustrator is running
On OS X or not from a perl script. How can I do it?

"ps" doesn't list the processes like Illustrator.

A late arrival which hasn't been mentioned so far:

$ killall -0 Illustrator 2>/dev/null && echo "Illustrator is running"

Broadly, killall sends a signal to any process with a name matching its final command-line parameter. (See the man page for chapter and verse.) Here we're sending signal zero instead of the default SIGKILL. Signal zero isn't really a signal at all: it acts as a "could I send a signal if I wanted to?" query. If a signal could be sent -- that is, if Illustrator is running -- killall exits with status zero (success), so the next command in the pipeline gets run; otherwise with one (failure), terminating the pipeline. The 2>/dev/ null junks killall's diagnostic in the event that Illustrator isn't running.
--
Dominic Dunlop

Reply via email to