Re: do shell script flaw
Re: do shell script flaw
- Subject: Re: do shell script flaw
- From: Paul Skinner <email@hidden>
- Date: Sun, 06 Dec 2009 15:27:37 -0500
On Dec 6, 2009, at 12:17 PM, Axel Luttgens wrote:
Le 6 déc. 2009 à 16:36, Paul Skinner a écrit :
Since top is normally interactive and you don't need that I'd use
the -l flag to run it only once. The tech note for do shell script
even cites this interactive shell app as an example of problems and
limits of these apps.
And I get the same result from...
do shell script "top -tl 2 -o cpu -p '$aaaaaa $cccc
^bbbbbbbbbbbbbbbb'"
as I do from...
do shell script "top -l1 -tl 2 -o cpu -p '$aaaaaa $cccc
^bbbbbbbbbbbbbbbb'"
Does that help the issue?
Paul
Which OS version is this?
I'm on 10.5.8 here. And I was wrong, Emmanuel's top command did
produce results from it's both samples.
Seems to be 10.5.x, since it's the only one that came with a top
command allowing for both -t and -p options.
On the other hand, doesn't the "-tl 2" part already hinder the
interactive behavior, by requesting two samples only?
Axel
I really should have removed the second instance of l in my post.
Only setting -l 1 will prevent top from preparing the terminal for
interactive display though. I don't know what all that entails. I have
always used the -l 1 with top from applescript simply because Apple
suggested it.
I don't know the purpose of the top call in the original code, or why
it needs to run more than once from do shell script. I assume that
it's doing more than listing processes, and must need to run over time
to accumulate data.
If it the intention is to sample processor usage over time then it
would probably be better to set the samples to two, then vary the
delay to the sample time you desire, while in accumulate mode. That
way the final result is precalculated for you.
set procCount to 3--busiest procCount processes over the last 4
seconds sorted by total processor time.
(paragraphs (-1 * procCount) thru -1 of (do shell script "top -l 2 -s
4 -R -ca -o time -n " & procCount))
-->{
"79987 Mail 2.5% 0:00.10 68 0 0
465 275 1168 1576 554 ",
" 54 WindowServ 2.4% 0:00.10 195 0 0
830 579 922 1225 316 ",
" 0 kernel_tas 1.5% 0:00.06 0 0 0
22721 22355 0 0 1665 "
}
bonjour,
Paul
_______________________________________________
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