New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Terminal Kill command


Post Reply New Thread Subscribe

 
Thread Tools
zeroq

 
Member Since: Sep 21, 2008
Location: Ashby de la Zouch, UK
Posts: 3
zeroq is on a distinguished road
Mac Specs: MacBook 2GHz Intel C2D

zeroq is offline
I use Remote Desktop at work to keep an eye on pesky kids in the shop.
I have already set some preset Unix commands to kill safari, mute the computer and that sort of thing.

But, the killall command will not kill Firefox. I have thought about killing the PID but then, that changes all the time and it takes ages to get the correct PID back from the host machine.

at first i thought Remote Desktop was having trouble handling 3rd party apps but i just tried killing firefox on my own machine and it doesn't kill it then either. I just get "No matching processes belonging to you were found"

Does anyone know how I can get Terminal to kill firefox, without first finding the PID?

Dan.
QUOTE Thanks
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,624
Dysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant future
Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff

Dysfunction is offline
killall is the executable to kill by name, you'll need the PID for kill. Why is ps -ef | grep firefox taking forever? That should return pretty quickly, then you can kill it using kill. and.. does kill all -z firefox not work either?

mike
This machine kills fascists
Got # ? phear the command line!
QUOTE Thanks
zeroq

 
Member Since: Sep 21, 2008
Location: Ashby de la Zouch, UK
Posts: 3
zeroq is on a distinguished road
Mac Specs: MacBook 2GHz Intel C2D

zeroq is offline
Ahh, that was confusing.

In my first post all of my "Kill"'s were "killall"'s if that makes sense.




If killing firefox without first finding the PID isn't particularly easy, is there a way to send a command that will emulate keystrokes?

Dan

An infinite amount of Infinity's

http://www.zeroq.co.uk
QUOTE Thanks
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,624
Dysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant future
Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff

Dysfunction is offline
Finding the PID is pretty simple.

Here's a screenshot of me killing firefox.





Now, since we're talking killall... killall -z firefox
will kill all PID's matching the name firefox of your assumed user, the z tells it to also kill any zombied processes.

ps -ef | grep firefox

this will list all running processes, then search through that list and display all that include the word firefox. If you take a look at my example, the first # is the process owner ID (me) the second is the PID.

mike
This machine kills fascists
Got # ? phear the command line!
QUOTE Thanks
zeroq

 
Member Since: Sep 21, 2008
Location: Ashby de la Zouch, UK
Posts: 3
zeroq is on a distinguished road
Mac Specs: MacBook 2GHz Intel C2D

zeroq is offline
Ah right, okay.

One final hurdle.

Is there a way of automating the second command by taking the correct PID and actioning the command "kill 1234".
The reason for this is the command will be executed via the "Send Unix Command" feature of Remote desktop, run from one of the shop checkouts.

For example;

osascript -e 'set volume 0'

is the command sent to mute all of the computers, but it only does one job.

this new command need to get the output of the first command and then use the correct part of it in the next command.

Perhaps an Applescript for this command too?

An infinite amount of Infinity's

http://www.zeroq.co.uk
QUOTE Thanks
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,624
Dysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant future
Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff

Dysfunction is offline
Try something like...

ps -ef | grep -v 'grep' | grep firefox | awk '{ print $2; }' | xargs kill


applescript I can't help you with

mike
This machine kills fascists
Got # ? phear the command line!
QUOTE Thanks
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,624
Dysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant future
Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff

Dysfunction is offline
Oh, thought of something else... since killall will assume username.. you could try..

killall -u <username> firefox

mike
This machine kills fascists
Got # ? phear the command line!
QUOTE Thanks

Post Reply New Thread Subscribe


« Xcode Help! | Xcode, Safari, and Finder not playing nice »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Terminal command question MACGIRL34 OS X - Operating System 1 12-12-2007 04:26 PM
This command doesn't work in terminal of Leopard Server txn OS X - Operating System 4 12-02-2007 12:31 PM
Creating an application to run a terminal command on startup? Starky OS X - Apps and Games 7 11-26-2007 11:57 PM
Sleep command doesn't work in terminal greenapple OS X - Operating System 1 02-08-2005 11:25 AM
looking for a terminal emulator and command shell in Mac OSX CandiMarie OS X - Operating System 9 03-05-2004 03:53 PM

All times are GMT -4. The time now is 12:33 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?