Code to close terminal window?

I am running code in an IDE and want to be able to have any existing terminal window close before the code is run.  This way I don't have to keep closing them manually every time I run the code again.  I'm coding in C.  Any ideas?
Thanks

What about setting the
Terminal -> Preferences -> Settings -> Shell -> When the shell exits: Close the window
Now just make sure that the last thing your script does is exit from the shell and your window will be closed.
Then again, do you "Really" need a Terminal session to run your code?
That is to say, running programs and scripts can be done without needing a terminal session.  The Terminal session is just a window to the command line, and you do not need to display anything via the Terminal display, then there is no reason to have it open to run your program.
You can use Applescript ("do shell script" statement), or Automator ("run shell script" action), or you can use a 3rd party utility such as Platypus that will put your program or script in a double clickable app that does not need a Terminal session.
Another option is to use a different Terminal emulator, such as iTerm which also has the ability to close the window when the shell exits.  It can even automatically quit iterm when the last window is closed.

Similar Messages

  • Sample C++ code to open terminal window ?

    Friends:
    I'm using the Command Line Utility XCode C++ tool:
    Does anyone have sample C++ code which opens the terminal window to show the products of the run? I want to include this code at the beginning of my C++ code so that the window opens automatically during the run.
    If I can set the terminal window properties that would also be appreciated, though not necessary.
    Thanks amigos,
    Migs

    Hi Migs,
    Just to perhaps explain why folks were confused by your question and maybe also clarify the answers that you've already been given...
    While you're *in the process of writing* a command-line tool within Xcode it's usually easiest to just "Build & Run" your tool totally within Xcode's environment. That's why Xcode provides it's own integrated "Console" window - so you can view the results of your tool's execution without having to leave the Xcode environment. This saves you the trouble of having to switch back and forth between Xcode and Terminal during the development process.
    However, typically, a command-line tool is ultimately intended to be run from the Unix command-line (ie Terminal.app). So *once you're finished writing and debugging your tool* you will then generally want to run your tool from Terminal (and not have to launch Xcode). You can find the final executable in the "build" folder of your Xcode project. And at this point you would typically launch Terminal and execute your tool from Terminal's command prompt. Once your tool is finished there's no need to launch Xcode every time you want to run it.
    In Terminal you would just type:
    /path/to/your/tool
    You might even want to move the final executable to a directory that's in the Terminal's $PATH so the shell could find it using only it's name without requiring the path.
    Steve

  • How to close Terminal Windows and terminate processes with Applescript?

    I'm trying to quit the Terminal via AppleScript. I need to run 4 different Terminal scripts on a server but would also need to restart this server every day automatically... and my favorite choice would be to do this properly.
    I suceeded terminating all other applications, cleaning folders and sending messages, but I did not find a solution quitting the Terminal!
    When I tell it to quit, it asks if I want to terminate all processes, even if I use the "ignoring application responses" command. The Terminal gets stuck on that dialog box and one has to manually hit "Terminate".
    Anyone knows about a solution how to avoid this prompt or how to default "Terminate"? There must be something like "close window 1 with process terminate", or?
    Many thanks in advance!

    :-))) Sometimes the answer is so easy... Thanks a lot!

  • Express install always asks user to close browser window

    Is Adobe in charge of the code that closes browser windows at
    the end of express install?
    I'm currently using SWFobject 1.5 to embed my flash movie
    with express install active and neither IE6, IE7 or firefox will
    automatically close once express install has finished. It used to
    be that IE would close and reopen the window, firefox never used to
    but that's a different topic I'm sure.
    Perhaps Adobe changed something?

    Never mind, found the answer here:
    Re: Closing brower window

  • Close a window in a post form trigger in a form with calls to new forms

    All,
    I am trying to close the browser using examples from metalink and this forum. I am placing the code in a post-form trigger as directed by the example. The problem I am having is that this is a menu type screen that includes buttons that take the users to a new form. So, when any of the buttons pressed on the menu screeen, including the Exit button, The Post-Form trigger fires and tries to close the window. I also noticed I should place the trigger in the last closing form and have done that.
    I then tried putting the code to close the window in the Exit when button pressed trigger, and that doesn't seem to be working either.
    Any help would be greatly appreciated.
    Joe

    I wonder why the feature isn't built-in to the OS, even as an option.  It's convenient to be able to minimize a window in place, so you don't have to keep going to the dock to reopen it...  

  • [svn] 4628: Fix FB-15947: Terminating debug session closes Safari window including tabs not launched by debugger

    Revision: 4628
    Author: [email protected]
    Date: 2009-01-22 15:45:06 -0800 (Thu, 22 Jan 2009)
    Log Message:
    Fix FB-15947: Terminating debug session closes Safari window including tabs not launched by debugger
    Ticket Links:
    http://bugs.adobe.com/jira/browse/FB-15947
    Modified Paths:
    flex/sdk/trunk/modules/debugger/src/java/flash/tools/debugger/concrete/appleScriptCloseSa fariWindow.txt

    Revision: 4628
    Author: [email protected]
    Date: 2009-01-22 15:45:06 -0800 (Thu, 22 Jan 2009)
    Log Message:
    Fix FB-15947: Terminating debug session closes Safari window including tabs not launched by debugger
    Ticket Links:
    http://bugs.adobe.com/jira/browse/FB-15947
    Modified Paths:
    flex/sdk/trunk/modules/debugger/src/java/flash/tools/debugger/concrete/appleScriptCloseSa fariWindow.txt

  • I need the code for creating popup windows and code for open and close

    I can write the code for creating popup window , i am getting problem while trying to open and closing that popup windows.
    Can anybody help me in that pls ?
    Regards
    Sreeni.

    Hi
    For pop up window
    IWDWindowInfo windowInfo = (IWDWindowInfo)wdComponentAPI.getComponentInfo().findInWindows("PopWin");
    IWDWindow window = wdComponentAPI.getWindowManager().createModalWindow(windowInfo);
    window.setWindowPosition (300, 150);
    window.show();
    wdContext.currentYourNodeElement().setPopupAttribute(window);
    For closing window code
    IWDWindow window = wdContext.currentYourNodeElement().getPopupAttribute();
    window.hide();
    window.destroyInstance();
    For more infornation refer this link
    http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/20d2def3-f0ec-2a10-6b80-877a71eccb68&overridelayout=true
    This link is very useful for you.
    Regards
    Ruturaj
    Edited by: Ruturaj Inamdar on Aug 13, 2009 9:10 AM

  • Terminal window: how to close it ?

    Hello, everytime i switch on my macbook the Terminal window appears on the dock, it opens and it stays open. It all started 2 months since then it happens everytime. It is automatic. So i do switch it off ? how do i make sure that it doesnt open anymore when i switch on my macbook ? thanks for the help folks

    thanks Niel but it didnt work out. Control-click did nothing and same goes with preferences account which had marked just ituneshelper. Below what Terminal write at login
    macbook-di-andrea-zaccardi:~ andreazaccardi$ /System/Library/Frameworks/JavaVM.framework/Versions/A/Commands/java ; exit;
    Usage: java [-options] class [args...]
    (to execute a class)
    or java [-options] -jar jarfile [args...]
    (to execute a jar file)
    where options include:
    -d32 use a 32-bit data model if available
    -d64 use a 64-bit data model if available (implies -server, only for x86_64)
    -client to select the "client" VM
    -server to select the "server" VM
    -jvm is a synonym for the "client" VM [deprecated]
    -hotspot is a synonym for the "client" VM [deprecated]
    The default VM is client.
    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
    A : separated list of directories, JAR archives,
    and ZIP archives to search for class files.
    -D<name>=<value>
    set a system property
    -verbose[:class|gc|jni]
    enable verbose output
    -version print product version and exit
    -version:<value>
    require the specified version to run
    -showversion print product version and continue
    -jre-restrict-search | -jre-no-restrict-search
    include/exclude user private JREs in the version search
    -? -help print this help message
    -X print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
    enable assertions
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
    disable assertions
    -esa | -enablesystemassertions
    enable system assertions
    -dsa | -disablesystemassertions
    disable system assertions
    -agentlib:<libname>[=<options>]
    load native agent library <libname>, e.g. -agentlib:hprof
    see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
    load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
    load Java programming language agent, see java.lang.instrument
    logout
    [Processo completato]

  • Code for close window

    I have a popup html page. I want to close the window , whenever i clicks the " CloseWindow" button.

    Make a item of type "button" and not "submit button".Put destination url property of the item as
    javascript:window.close()
    --Mukul                                                                                                                                                                                                                                                                                           

  • [SOLVED] keeping terminal window open for scrot keyboard shortcut

    Hey,
    Im trying to bind a keyboard shortcut to scrot with the -s command (for selecting window). Normal scrot command works fine straight away, but with the -s command a terminal window needs to be open that waits for the selection. i have created a file called lscrot with the following code:
    1 #!/bin/bash
    /usr/bin/terminal --working-directory=$HOME/dump/ --geometry 0x0-0-0 -e "/usr/bin/scrot -s"
    i have put the file in /usr/bin folder with 755 permissions.
    if i right click the file and choose "execute", the new terminal window will stay open and i can select an area to take a screenshot of, but when i bind it to a shortcut key (using xfce) the new terminal window will close immediately rendering the shortcut useless.
    how does one fix this?
    thanks
    Last edited by iOfWhy (2012-06-10 13:41:55)

    hmmm, ok. binding keys to /usr/bin/scrot works fine, but /usr/bin/scrot -s does not. dont really know where to begin searching for a fix...
    EDIT: im assuming there is something elementary i am missing. after further testing, launching for example scrot ~/dump/test.png from console works fine, but not when i bind it to a keyboard shortcut. however, scrot test.png works to bind. does anyone know anything more about XFCe and binding keyboard shortcuts?
    EDIT2: ok so im honing in a little bit, i realised that the first times i use the keyboard shortcut it works. forcing the terminal window to stay open after command has been executed i see following error:
    giblib error: couldn't grab keyboard:Resource temporarily unavailable
    Searching the net i found old bug that was closed without (seemingly) being solved.
    https://groups.google.com/group/linux.d … 2056017d9a
    Any ideas?
    EDIT3: ok so found a solution, "sleep". Adding sleep 0.1 to the top of the screenshot script seemed to help. seems you need to give sometime to release the keyboard for scrot to use. would still be great if anyone knew how to get it to work by using a direct command in the keyboard shortcut bindings. ie binding in straight to "scrot -s". using Alt+F2 then typing in scrot -s works fine, so i really dont see why i cant bind a keyboard command straight to that.
    NOTE: how do i see xsession errors? I find no .xsession-errors file in my home directory. been searching for months.
    Last edited by iOfWhy (2012-06-10 13:33:56)

  • Closing Terminal window tabs shrinks Terminal window height

    Open a Terminal window, press Command-T to create a tab, and then Ctrl-D to close that new tab, the Terminal window height decreases by one row.
    This most certainly appears to be a bug. How do I report this to Apple?

    I am also experiencing this problem, however if you use the Basic setting the problem doesn't exist.
    I am using Novel and I have the problem. It's quite annoying.
    I noticed that if you set the fontsize to 12 then this problem exhibits, however if I change the size to 11pt or 10pt (10 is the default for Basic, 12 is default for Novel) then I don't have the bug.
    Message was edited by: TonyKL

  • Keyboard shortcuts: adding service to open a Terminal window not being saved

    Hi
    Objective: A shortcut to open a terminal window with the path of the 'in-focus' Finder window (Mavericks).
    Solution (that doesn't work): Apple Menu/System Preferences/Keyboard
    Select: Shortcuts
    Select: Services
    Check box for: New Terminal At Folder
    Close System Preferences
    This approach seems to be advised on quite a few sites. When I do it, the service I add simply doesn't get saved. I go back into the System Preferences and look under the path above and see that the box for New Terminal Åt Folder is unchecked.
    Any help in being able to achieve my objective would be greatly appreciated :-)

    Those things are saved as part of the workspace. It sounds as if the current workspace file has become corrupt. Close ID, then go to your user profile and you'll find the workspaces folder under \Application Data\Adobe\InDesign\Version 6.0\<language>\Workspaces. Delete the "current" xml file for the workspace and restart ID. The workspace will be restored to the conditions set when it was saved, but hopefully will remember changes again when you close the program.

  • (SOLVED) Closing a terminal window

    When I am through using the terminal window, I hit the X at the top right corner but get this message: There is still a process running in this terminal. Closing the terminal will kill it.
    Why do I get this? I think I have nothing running. is there a bug?
    Last edited by mcduling (2011-12-19 22:23:54)

    It is complaining because you are still running su. That's a fair warning, not a bug.
    If you don't like it, use sudo instead. It's safer anyway than leaving a terminal sitting around in su-mode for arbitrary lengths of time.
    Edit: btw, if you have run su to gain root access, and you want to close the terminal, you can get out of su by typing "exit". Then you should be able to close the terminal.
    But really, don't use su. That's just asking for trouble. Sudo is your friend.
    Last edited by /dev/zero (2011-12-19 09:59:43)

  • Closing active terminal window with applescript

    I made a very basic script to lock my screen, and I like how it works. Some of my co-workers would also like it but it has one problem.
    When the script runs, a terminal box pops up at the end saying [process complete]. I can click through this and I don't care, they do.
    I can't just killall terminal because we use terminal and that could kill our work.
    We sometimes need to see output from a script and like the process complete, so don't want to reconfigure our systems to never display it.
    I'm trying to find a way to use applescript or something to kill the active terminal window, or the window with the title of LockScreen or something.
    Anyone have an idea?
    I was hoping something like this would exist but it doesn't seem to: tell application "Terminal" to close window

    Here is an easy approach.  Start Applications -> Automator
    Select Application
    In Automator search for "Start Screen Saver".  This should be under Library->Utilities
    Drag "Start Screen Saver" to the right side panel.
    Save the Automator app.
    If the user has System Preferencs -> Security -> Require Password ... set, then one the screen saver has started running, it will require the user to enter their password before getting control back.
    This Automator app can be double clicked, it will not require the terminal.
    With respect to your script.  If this is a shell script, AND if you wish to continue using it, then you could create an Automator app that uses "Run Shell Script" under Automator Library->Utilities.  This will also NOT require the use of Terminal, however, be aware that when Automator runs a shell script it DOES NOT have the same environment as when you are running a shell script at your Terminal prompt.  There are very few environment variables set, and for example the USER, HOME, current working directory, PATH, etc... may not be the same.  If you have dependencies on specific environment information, you may want to write a simple automator script the using "Run Shell Script" to output various environment information into a file so you can see what you have to work with
    (id -a
    pwd
    echo "$#"
    echo "$@"
    printenv
    ) >/tmp/automator.environment.txt

  • How to Close external window?

    Hi Experts,
    1) For one of the development requirements, I am required to open my application in
    external window. For the same, I have changed the property of the iView  and page to
    launch the iView in an external window and not to display in content area. Now, I am
    able to display the application in a new window as per the requirement.
    Now, I want to close this window from a button event on the screen, but can't find a way to close it.
    If anyone's having an idea over it, that will be greatly appreciated???
    2) Also, in another application, I am downloading data into excel sheet and the download
    opens in a new window. Once the user clicks on the option (SAVE, OPEN, CLOSE),
    the blank window should close which works well in IE 7 but in IE 6 the user says the blank
    window is visible and they have to close it manually.
    I am using the following code for this:
    excelCSVFile = new FileInputStream(f);
    IWDCachedWebResource cachedWebResource = null;
    if (excelCSVFile!= null)
    cachedWebResource = WDWebResource.getWebResource
    excelCSVFile, WDWebResourceType.getWebResourceType(
    "xls","application/ms-excel"));
    cachedWebResource.setResourceName(fileName);
    wdContext.currentVn_XL_SheetElement().setVa_Resource(cachedWebResource.getURL());
    workbook.close();
    * BEGIN: Open new window: download button
    IWDWindow win =  wdThis.wdGetAPI().getComponent().getWindowManager().createExternalWindow
    (cachedWebResource.getAbsoluteURL(),"Print Content",false);
    win.setWindowSize(0,0);
    win.removeWindowFeature(WDWindowFeature.ADDRESS_BAR);
    win.removeWindowFeature(WDWindowFeature.MENU_BAR);
    win.removeWindowFeature(WDWindowFeature.TOOL_BAR);
    win.removeWindowFeature(WDWindowFeature.STATUS_BAR);
    win.setWindowPosition(200,200);
    win.show();
    * END: Open new window: download button
    For this if I try win.destroy() or win.close() or win.hide(), after win.show
    this doesn't shows the download options at all (quite obviously   ).
    I want to close this blank window automaticaaly once the user selects
    any option for download. Is there any solution to this or am I doing something wrong?
    Helpful answers will be appreciated. Thanks in advance.
    Regards,
    Gaurav Bhardwaj

    Hi Gaurav,
    If the external window contains the view of the wd component then only you can close the window.
    Try like this:
    Create a context attribute of IWDWindow in the calling view - component - called view and map them in all controllers.
    //set the context attribute  in calling view
    win.show();
    wdContext.currentContextelement().setWinref(win);
    * END: Open new window: download button
    In onActionxxx event of the downlload button
    // close the window
    wdContext.currentContextelement().getWinref().destroyInstance();
    Regards,
    Siva

Maybe you are looking for