Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Using the terminal to quit a GUI program UNIX
[Editor's note: See the comments for the answer to the question.]

Does anybody know how to quit a GUI program through a telnet session? I can open GUI programs through telnet but can't figure out how to then quit that same program. PS won't show GUI programs so I can't KlLL them. Any help is appreciated.
    •    
  • Currently 3.00 / 5
  You rated: 3 / 5 (5 votes cast)
 
[16,328 views]  

Using the terminal to quit a GUI program | 10 comments | Create New Account
Click here to return to the 'Using the terminal to quit a GUI program' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Try the options..
Authored by: robg on Mar 14, '01 05:31:25PM
I think what you're looking for is ps -x, where the "-x" option adds "information about processes without controlling terminals" to the standard output. Your GUI jobs will now be listed.

The challenge at that point is figuring out which job to terminate. Cocoa apps are easy - they're listed by name. Carbon apps are tough, as they're all "LaunchCFMApp" (hope this changes in final!). Classic is toughest of all, since the OS sees it as an application. You can't just quit one Classic app, you have to quit Classic in general.

[ Reply to This | # ]
Trial and error method to identify a carbon app
Authored by: robh on Mar 14, '01 06:40:24PM

Using trial and error, and access to the GUI (so no use to the original poster) you can pause a running app with "kill -STOP process-number" and then try to use it. If the app has been paused then you'll see the spinning wheel pointer and you won't be able to interact with the app. If you picked the right process number you can "kill -KILL process-number" to zap it. If you picked the wrong process number you can resume the app with "kill -CONT process-number".

FYI, "kill -STOP" is equivalent to hitting CTRL-Z to pause a running process in a terminal shell, and "kill -CONT" is equivalent to resuming it with the "fg" command.

"kill -STOP" is handy for pausing (as root) someone else's cpu hungry process while you run something more important. You can "kill -CONT" the process when you're finished.



[ Reply to This | # ]
ps -cax
Authored by: mspring on Mar 15, '01 11:39:58AM

Do a ps -cax. This will display all processes, listed by the command that was used to start them.

-Matt



[ Reply to This | # ]
Classic Apps
Authored by: Anonymous on Mar 15, '01 08:39:37PM

Just remember Classic apps just show up under a generic process name, that I forget offhand, but is the same fo all Classic apps.



[ Reply to This | # ]
You can use Applescript
Authored by: bewebste on Mar 15, '01 09:38:18PM

There is a command line app named osascript that will let you execute Applescripts from the terminal. In DP4, and I think in the beta, you must specify the full path, /usr/bin/osascript in order for it to work, but this should be fixed in the final. The quick way (let's say we want to quit Internet Explorer) is:

% osascript 'tell application "Internet Explorer" to quit'

You can also pass in the name of a file with Applescript source, or an Applescript compiled using osacompile, another command line tool. You should be able to quit any Cocoa, Carbon, or Classic app (and I'm guessing Java apps, too), assuming that the app isn't frozen.



[ Reply to This | # ]
You can use Applescript
Authored by: ewilen on Aug 23, '11 06:26:05PM
Thanks so much. But I had to use osascript -e.

[ Reply to This | # ]
Why use terminal?
Authored by: Anonymous on Mar 17, '01 01:51:51PM

Why would you use the terminal, when there's a sweet little GUI function to do this? Just hit Apple-option-esc and select the app to force quit. This works regardless of app's statusd (unlike AppleScript) and can force quit any process.

"I love systems, their applications excepted". George Sand (translated from French)



[ Reply to This | # ]
Why use terminal?
Authored by: Anonymous on Mar 17, '01 06:49:02PM

Because I want to quit them REMOTELY.



[ Reply to This | # ]
Kind of like Macsbug...
Authored by: Anonymous on Mar 19, '01 10:09:57AM

The other reason to use terminal is that you get to see all processes, like hz in macsbug used to do. The force-quit dialog only shows apps with a GUI (I think -- I'm pretty sure apps you write as daemons/servers won't show up here.)



[ Reply to This | # ]
Why use terminal?
Authored by: Anonymous on Mar 22, '01 07:46:41AM
One Reason to use the Terminal is the fact, that the GUI may crash, preventing you from seing your mouse cursor, etc.

I had such situations when Classic Apps that ran in Full screen@256 colors (old games) crashed. the color table is sometimes modified and you can't really access your system via gui. However, over a LAN, you can still log in and kill the offending process.

[ Reply to This | # ]