osx - AppleScript to force quit Java (JAR) programs? -


hello,

i run java (jar) application on mac os. using applescript run java program , works fine. now, use applescript close java program. need force quit java program. used following applescript,

set app_name "npc" set the_pid (do shell script "ps ax | grep " & (quoted form of app_name) & " | grep -v grep | awk '{print $1}'") if the_pid not "" shell script ("kill -9 " & the_pid) 

the applescript runs java program called "npc.app" when run "npc.app" shows npc , npc.npc on activity monitor application. above code set remove npc application not remove either npc (this "npc.app") or npc.npc (this java program). following error,

error "sh: line 0: kill: 1180 1182: arguments must process or job ids" number 1

1180 being pid npc , 1182 being pid npc.npc in activity monitor.

what correct applescript force quit java program?

try using pkill instead:

do shell script ("pkill -9 npc*") 

some examples here.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

c# - Unity IoC Lifetime per HttpRequest for UserStore -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -