Récupérer un PID avec AppleScript

Clarusad

Membre actif
5 Février 2004
398
9
Bonjour à tous,
J'aimerais trouver le PID d'un processus avec AppleScript ; avec le code suivant ça fonctionne et parfois pas (surtout ce qui tourne en tâche de fond, comme par exemple : "iCalAlarmSceduler"). J'ai même essayé en utilisant le chemin POSIX, mais rien y fait !
Serait-il mal écrit ? Auriez-vous une autre façon de faire ?
Merci de m'aider.

Bloc de code:
set the_lines to paragraphs of (do shell script "ps -U $USER")
set the_app to "NOM_APPLICATION"
set the_line to ""
repeat with this_line in the_lines
	if this_line contains the_app then
		set the_line to this_line
	end if
end repeat
if the_line is "" then return
set the_pid to word 1 of the_line
get the_pid