# quit applications remotely



## a-bort (Sep 4, 2003)

Since I'm able to open applications, folders or whatever in the macosx-way within the terminal (and thus also remotely) with the 'open' command, i'm hoping there is also a command that does the reverse. 
So closing an application/folder/e.g. without using ps auxc and kill...

Anybody knows how to do that?
Thanks..


----------



## Timoken (Sep 5, 2003)

well, some applications ask sth like "unsaved documents, quitanyway?" etc. you wont be able to confirm that via shell so you wont be able to quit those apps properly. i just use kill (only with the apps where i know nothing bad can happen)
i just type "top" and choose my process and kill'em by number


----------



## a-bort (Sep 5, 2003)

hmm.. didn't think about the applications asking things...  
Well, i could just use an applecript for the application where i needed it for, but for the rest it's suddenly very clear why it's not such a good idea (and i guess it doesn't excist) because of your answer..
Thanks Timoken!

Still i'm curious if it does exist..


----------



## mr. k (Sep 5, 2003)

it's not particularly to end a process remotely a-bort, but it's also not particularly graceful on the average.
A manilla finder app can generally be axed by doing two commands - 
	
	



```
ps -aux | grep <keyword>
```
 and 
	
	



```
kill <PID>
```
Now Here's an example of me killing Mozilla Firebird - 
	
	



```
[kjell:~] kjell% ps -aux | grep Mozilla
kjell 16334   2.2  5.9   230968  15476  ??  S     7:26PM   0:51.15 /Applications/browsers/Mozilla Fi
kjell 16513   0.0  0.0     1116      4 std  R+    8:21PM   0:00.00 grep Mozilla
[kjell:~] kjell% kill 16334
[kjell:~] kjell% uptime
 8:22PM  up  4:06, 3 users, load averages: 0.44, 0.39, 0.38
[kjell:~] kjell%
```
As you see, the first line corresponds to Mozilla Firebird.  The second item in the row is the PID of the process, and then you just issue kill. But the kill command is the equivalent of Force Quit, and won't save changes or anything.  By the way, grep is case sensitive.
Here is the column header for the ps -aux output (just for refrence) - 
	
	



```
USER    PID %CPU %MEM      VSZ    RSS  TT  STAT STARTED      TIME COMMAND
```
And yes, I do hate how the board handles really wide posts.  Why can't the left margin just always be the same!


----------



## a-bort (Sep 5, 2003)

Thanks mr K, I hope this might help people who don't know about the very usefull kill command!

I already know how to use kill.. and use it often the way you subsribed. It's just that i don't always want to force quit my applications. The application where i might just use an applescript for stores some data when you quit automatically, wich is important for me. 

Maybe there's an other way to quit an app from the terminal without forcequiting it??


----------



## symphonix (Sep 8, 2003)

You might use osascript to call an Applescript, perhaps.


----------



## Timoken (Sep 9, 2003)

maybe you can use a socalled "ae quit" via applescript. this is a command that's used for example if you shut down your computer when applications are running. is there a possibility to open a applescript via shell and give it some variables like e.g. applicationnames? so you could write an universal applescript that sends an "ae-quit", open it and give it the name of the application to quit.
anyway. you're still f***ed if the application has unsaved documents


----------



## Da_iMac_Daddy (Sep 24, 2003)

www.macdevcenter.com they just had an article on this check it out.


edit: http://www.macdevcenter.com/pub/a/mac/2003/09/19/remote_control.html


----------



## michaelsanford (Oct 5, 2003)

If it's an app with a GUI, I would definately use an AppleScript to tell the app to quit instead of using 'kill'.

Just make scripts that contain a block like

```
try
tell application Finder to Quit
end try
```

Just make sure the Quit command (or equivalent) is contained in that app's dictionary...


----------

