OT - shell script to kill a process
kray at sonsothunder.com
Tue Jul 10 11:58:49 CDT 2007
On Tue, 10 Jul 2007 09:28:01 -0600, Chris Sheffield wrote:
> I've got another question for you though. It concerns the 'cut -d\
> -f2' part of this. This doesn't seem to be working correctly. Can you
> explain more what's supposed to happen here?
Yes, the "cut" basically extracts a delimited "chunk" of data from the
string. So run this part of the command in the Terminal with TextEdit
ps -awx | grep 'TextEdit' | grep -v 'grep'
I get this:
5460 ?? S 0:00.25
With a preceding space in front of the 5460. So as I put in my previous
>> ( cut -d\ -f2) = Extract ("cut") the second space-delimited "word"
>> in the resulting string ("-d" means use a delimiter, "\ " is the
>> delimiter to use (has to be escaped because spaces normally signify a
>> change of parameters, etc. on the command line), "-f2" means look for
>> the second space-delimited "field" in the string)
This means it should look for the second space-delimited chunk. So then
run it up to the end of the 'cut':
ps -awx | grep 'TextEdit' | grep -v 'grep' | cut -d\ -f2
I get "5460". This is then piped to the kill command to kill. Is it
possible you either (a) don't have two spaces between the "\" and the
"-f2" (if so you'll get a "bad delimiter" error message in the
Terminal), or (b) perhaps your process line isn't the same as mine?
Sons of Thunder Software, Inc.
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/
More information about the use-livecode