Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / June 2007



Tip: Looking for answers? Try searching our database.

Close terminal with .command file?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Scott - 22 Jun 2007 01:58 GMT
I'm fairly new to OS X and the mac platform in general. I just got all
my Perl scripts working (that were previous geared towards windows
platform), but I was only able to launch from the command line... I
didn't like this.

Anyhow, I was able to figure out that if I changed the extension
to .command, then I could double click from the desktop... or
wherever.

The .command works perfect, it launches a terminal and executes the
script (this is necessary because some of the scripts require input).
My new pet peeve is that the terminal remains open! I tired putting a
simple exit command, no dice... the terminal just says [logout]
process completed. Some quick searches as not given me much insight.

So, how can I go about closing the terminal after the script is
complete..? Or I should say, what do I need to add to the end of my
script to close the terminal?

Thanks in advance,

Scott
Michael Ash - 22 Jun 2007 05:04 GMT
> So, how can I go about closing the terminal after the script is
> complete..? Or I should say, what do I need to add to the end of my
> script to close the terminal?

Terminal->Window Settings...->Shell, under "When the shell exits:", you
can change the behavior of the window.

Obviously this only works on your machine, but if you intend to distribute
these things then distributing them as .command files isn't appropriate
anyway.

Signature

Michael Ash
Rogue Amoeba Software

Scott - 22 Jun 2007 14:35 GMT
I found a solution... I put this in there:

kill -3 $(ps wax | grep "[T]erminal.app" | awk '{print $1}')

Its a bit brute, but it works.

SA
Michael Ash - 22 Jun 2007 15:08 GMT
> I found a solution... I put this in there:
>
> kill -3 $(ps wax | grep "[T]erminal.app" | awk '{print $1}')
>
> Its a bit brute, but it works.

If you plan on distributing these things, could you tell me where they can
be found and what they're called so I can make sure I never, ever end up
using them by mistake?

Signature

Michael Ash
Rogue Amoeba Software

Tony Walton - 22 Jun 2007 15:22 GMT
> I found a solution... I put this in there:
>
> kill -3 $(ps wax | grep "[T]erminal.app" | awk '{print $1}')
>
> Its a bit brute, but it works.

Thus trashing any other terminals the user happens to have open,
completely unconnected with your app.

I'd call that buggy.

Signature

Tony

Scott - 22 Jun 2007 15:41 GMT
I agree it's nasty... but how do you go about closing that specific
terminal. Or even better yet, how can I tell it to not even show the
terminal? When I run Perl's on windows, you just the the command
window blink as it runs, then it closes... how can I emulate this...
gracefully?
Patrick Machielse - 22 Jun 2007 17:31 GMT
> I agree it's nasty... but how do you go about closing that specific
> terminal. Or even better yet, how can I tell it to not even show the
> terminal? When I run Perl's on windows, you just the the command
> window blink as it runs, then it closes... how can I emulate this...
> gracefully?

You might be able to use AppleScript (through the osascript command) and
'tell window 0 of application 'Terminal' to close' (or someting similar
that actually works).

patrick
Ben Artin - 22 Jun 2007 23:02 GMT
> I agree it's nasty... but how do you go about closing that specific terminal.

Instead of using a .command file, use a .term file. The way you make one of
those is so open a new window in Terminal, set its settings the way you want
them, then use File > Save. All the window settings get saved, and you get to
specify which command is to be run when the file is loaded.

hth

Ben

Signature

If this message helped you, consider buying an item
from my wish list: <http://artins.org/ben/wishlist>

I changed my name: <http://periodic-kingdom.org/People/NameChange.php>

Bob Harris - 22 Jun 2007 23:50 GMT
> I agree it's nasty... but how do you go about closing that specific
> terminal. Or even better yet, how can I tell it to not even show the
> terminal? When I run Perl's on windows, you just the the command
> window blink as it runs, then it closes... how can I emulate this...
> gracefully?

-- AppleScript wrapper to execute UNIX shell scripts
-- with a drag and drop interface.
-- Found basic script at http://MacOSXHints.com
-- cmdenv is a program I originally wrote back in
-- 1985 to help me see what a fork/exec'ed program
-- was seeing.  I find it highly useful.
-- Bob Harris   4-Jun-2005

on open filelist
repeat with i in filelist
 -- do shell script "my_command " & quoted form of POSIX path of i
 do shell script "yourScriptHere >/dev/null " & quoted form of
POSIX path of i
end repeat
end open

-- NOTE: the do shell line may be line warpped.  
-- It is suppose be one line ending in "... POSIX path of i"
-- so if it has been lined wrapped put it back together again

-- Use the Applications -> AppleScript -> Script Editor
-- to create an executable AppleScript from the above.

                                       Bob Harris
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.