Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Applescript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Applescript
Authored by: SOX on May 18, '06 08:07:01AM
here's an apple script wrapped version of this.

set ttt to " 3.0 0.4"
display dialog "Process_ID  High_load_stop Low_load_continue" default answer ttt
set ttt to the text returned of the result

set command to "perl -we 'exit 0 if fork; die unless @ARGV;$SIG{INT} =sub {`kill -s CONT $p`; die qq:bye now:};($p,$s,$c) = ( @ARGV,2.5,0.5);($sig,$w) = (qq:CONT:,30);$c1=$c2=$e1=$e2=0;$e2=30;while (1) { last unless  grep{ /^\\s*$p /} `ps x`;  ($x,$y,$z) = split /\\s+/,`sysctl vm.loadavg`; ($sig,$w,$e1,$e2)=(qq:STOP:,300,300,0) if ($y>$s) ; ($sig,$w,$e1,$e2) =(qq:CONT:,30,0,30) if ($z<$c);`kill -s $sig $p` ; print STDERR qq/ $p: $x $y $z   $sig  S:$c1 C:$c2 sec                /,chr(13); sleep  $w;$c1+=$e1;$c2+=$e2}' " & ttt 

do shell script command

paste this into the applescript editor then same it as an application. please note that the perls script part of this needs to be on a single line with no line breaks. This launches a background process to watch the app. The downside of this is there is no feedback about the run-state of the application as provided by the command line version. You can still use top to monitor it however.

[ Reply to This | # ]