Re: Applescript process id
Re: Applescript process id
- Subject: Re: Applescript process id
- From: Takaaki Naganoya <email@hidden>
- Date: Mon, 27 Mar 2006 12:46:42 +0900
- Thread-topic: Applescript process id
Jeremy,
This is very interesting theme. Identifying a unix process by name is very
interesting.
Apple engineers made mistakes in iTunes 5.x installer shell script to kill
"iTunesHelper" and "iTunes" by name. So they execute it *twice* in iTunes
6.x installer :-). It is stupid way.
I think that it is easy to get pid from multiple processes which have same
name. If we could return the result as list, there would be answer.
But Identiying process by grep is dangerous (like Apple). It returns not
only "iTunes" but also "iTunes Helper".
"cut" command will be the answer...
--
Takaaki Naganoya
Piyomaru Software
http://www.appleco.jp/piyomarusoft/
On 06.3.26 8:52 AM, "Jeremy Matthews" <email@hidden> wrote:
> Takaaki,
>
> This seemed really cool, though I'm trying this:
>
> set pid to (first word of (do shell script "ps ax | grep java"))
> do shell script "ps -xwwo %cpu -p" & pid
> get second word of result
>
>
> (without the error checking, of course).
>
> However, now I have to figure out how to handle it when there are
> multiple processes with the same name!
> Ideas?
>
> Thanks,
> jeremy
>
>
> -----------------------------
> How about this code?
>
> <AppleScript>
> set aPID to 1089 --example
> set b to getLoadAVGofProcess(aPID) of me
>
> --Get CPU Load of a Process indicated by Process ID
> on getLoadAVGofProcess(aPID)
> set aShellText to "ps -auxc -p " & aPID & " | awk '{print $3}' "
> try
> set a to do shell script aShellText
> set b to item 2 of (paragraphs of a)
> set b to b as number
> on error
> set b to 0
> end try
>
> return b
> end getLoadAVGofProcess
> </AppleScript>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden