I try to kill process which name i give in dialog:
display dialog "Kill Who??? " default answer “”
set what to text returned of the result
do shell script “kill -15 ps axww | grep -i
” & what
I try to kill process which name i give in dialog:
display dialog "Kill Who??? " default answer “”
set what to text returned of the result
do shell script “kill -15 ps axww | grep -i
” & what
Hi cirno,
you could use an other command which is more comfortable since you can name the process you want to kill:
(implemented since 10.2 as far as I rememeber)
NAME
killall – kill processes by name
SYNOPSIS
killall [-d | -v] [-h | -?] [-help] [-l] [-m] [-s] [-u user] [-t tty]
[-c procname] [-SIGNAL] [procname …]
DESCRIPTION
Killall kills processes selected by name, as opposed to the selection by
pid as done by kill(1). By default, it will send a TERM signal to all
processes with a real UID identical to the caller of killall that match
the name procname. The super-user is allowed to kill any process.
…
D.
I’m newbie in unix-commands.
This script works except it cant handle case insensitive text:
display dialog "Kill Who??? " default answer “”
set what to text returned of the result
try
tell application what to quit
–say “quit”
on error
do shell script "killall " & what
–say “error”
end try
Thanks
Hi cirno,
why do you want the user to enter the Application name?
Maybe you can do it this way?
tell application "Finder" to set theApps to (name of every process whose visible is true)
set theAppToKill to choose from list theApps
...
If you need to ask the user, you could use the first line of this script and compare each application name of this list with the name entered by the user. Since AppleScript compares case insensitive by default it will be found anyway. You now just have to take the correct name from the list and quit/kill it.
D.