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

Similar Messages

  • 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.

  • Unable to Open Terminal Window

    Hello,
    I am trying to do research on how to fix my current problem of not being able to open my terminal window.  When attempting to do so I get the following error message:
    You are unauthorized to run this application.
    The administrator has set your shell to an illegal value.
    I looked at some previous posts and some people said download iterm2 and put the following command: sudo chsh -s /bin/bash my_username.  After this enter password and it should be fixed.  However when doing that I get the following response: SC is not in the sudoers file.  This incident will be reported.
    Couple of things, firstly SC (which is me) is the administrator to this computer (this is my computer and there are no other users on it). 
    Either way can anyone give some suggestions on how to solve this problem so that I am able to open the terminal window.
    Much thanks in advance for anyones assistance.
    Sami

    Create a new administrator account in which to change your shell and also fix the sudoers file, which is apparently corrupt. It should have the following content:
    # sudoers file.
    # This file MUST be edited with the 'visudo' command as root.
    # Failure to use 'visudo' may result in syntax or file permission errors
    # that prevent sudo from running.
    # See the sudoers man page for the details on how to write a sudoers file.
    # Host alias specification
    # User alias specification
    # Cmnd alias specification
    # Defaults specification
    Defaults          env_reset
    Defaults          env_keep += "BLOCKSIZE"
    Defaults          env_keep += "COLORFGBG COLORTERM"
    Defaults          env_keep += "__CF_USER_TEXT_ENCODING"
    Defaults          env_keep += "CHARSET LANG LANGUAGE LC_ALL LC_COLLATE LC_CTYPE"
    Defaults          env_keep += "LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME"
    Defaults          env_keep += "LINES COLUMNS"
    Defaults          env_keep += "LSCOLORS"
    Defaults          env_keep += "SSH_AUTH_SOCK"
    Defaults          env_keep += "TZ"
    Defaults          env_keep += "DISPLAY XAUTHORIZATION XAUTHORITY"
    Defaults          env_keep += "EDITOR VISUAL"
    Defaults          env_keep += "HOME MAIL"
    # Runas alias specification
    # User privilege specification
    root          ALL=(ALL) ALL
    %admin          ALL=(ALL) ALL
    # Uncomment to allow people in group wheel to run all commands
    # %wheel          ALL=(ALL) ALL
    # Same thing without a password
    # %wheel          ALL=(ALL) NOPASSWD: ALL
    # Samples
    # %users  ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
    # %users  localhost=/sbin/shutdown -h now

  • I can't open a silverlight dmg file-it always opens Terminal window

    Hi,  I can't open a silverlight dmg file to watch netflix.  I am running Lion on my 2.66ghz iMac i5 with 10.7.3. I can download and install silverlight but when I try to open the file, it always opens the Terminal window.  Please Help.

    It sounds like all your launch services file associations have somehow been corrupted.  I suggest your reset the launch services bake to their initial default settings.
    The easiest way for you to do this is probably to get a maintenence utility like OnyX (download the Lion version for your case).  It has, among many other things, a way to rebuild the launch services.  Launch OnyX.  It will ask for your admin password and a window like below will be dispallyed.
    As you can see from the above picture in OnyX you select Maintenance, Rebuild tab, check the LaunchServices checkbox, and click the Execute button (not shown here but it's at the bottom of the window).
    Note, the above shows the window for the Snow Leopard version of OnyX.  I don't know if the Lion version is different since I don't use Lion.

  • [Solved] Have Cron Job Open Terminal Window

    I want to run a ping script every morning to check the liveliness and latency of specific servers. The script itself works fine but I can't figure out how to have cron open up a terminal window so I can see the script running.
    This is what I have so far:
    #runs /home/bran/pingservers.sh everyday at 8:30 am
    10 10 * * * env DISPLAY=:0 konsole -e ~/pingservers.sh
    But it doesn't open anything I don't even know if the job is even executing.
    Last edited by brando56894 (2013-05-20 14:25:42)

    I am unsure how to get the script to open a terminal, but the journal should have some information on whether the script is running or not and if there are any errors.
    brando56894 wrote:
    I don't even think cron jobs are running at all. I changed my job to
    1 * * * * /bin/echo hello world
    and it hasn't done anything...
    As far as the job above, I just wanted to note that you have it set to run on the first minute of every hour. If you were looking for every second minute, you would want the following:
    */1 * * * * /foo/bar
    Last edited by BluMongoose (2013-05-14 22:01:48)

  • Problems : Starting up with CDE and Opening terminal window in JDS

    Hi
    I installed Solaris 10 GA on the system having 2.8 GHz Dual Xeon processor with EM64T.
    Installation process was fine and completed. But, I have two problems with CDE and JDS.
    Firstly, in JDS, the graphical login comes up, works fine. After I login (as root or anyone), sometimes terminal window does not start up correctly. The windows for terminal apprear, but there is no display. Thus, I cannot use the terminal in JDS, while the other menus on launch panel (e.g. StarOffice) seem to work properly.
    Secondly, in CDE, I can login, the hourglass pointer appears and changes to arrow pointer. But then, there are no items except only the pointer and wallpaper.
    Both problems do not happen at every login time. when the problems happen, I have to reboot (in CDE/JDS) or re-login (in JDS). After some rebooting or re-login, things work fine again.
    Can everybody help me?
    Thanks

    I am not Adobe staff, but I have never heard of an "online upgrade". When I purchased my CS6 upgrade  from Adobe, they sent me an email with the serial.
    Who did you go through to get this upgrade?

  • Using same opened popup window

    Hi,
    I have a scenario where I have 4 button in a view and I have to open same external URL window for all 4 buttons.
    Now user wants to use same popped up window (if already opened). He doesn't want to open same window again and again.
    Currently I am using non-modal external window code to open this window.
    wdComponentAPI.getWindowManager().createNonModalExternalWindow(DAS_URL).show();
    Can you please tell me how do I achieve this req?
    Please help.
    Thanks and regards,
    Amey

    Modify your code to have a handle for your window:
    IWDWindow window = null;
    //when button is clicked:
    if (window == null) {
        window = wdComponentAPI.getWindowManager().createNonModalExternalWindow(DAS_URL).show();
    else {
        // do nothing, window is still open
    window.destroyInstance(); //this will close your window
    window = null;
    Hope this helps!
    Best regards,
    Robin van het Hof

  • Opening a window through masthead

    Hi,
    I am using the following code to open a window when clicking on a link in masthead :
    function ttsSuggestion()
         <%if (!isPreview){%>
         if (EPCM.getUAType() == EPCM.MSIE)
              var val = window.showModalDialog('TSHead.Suggestions','','<%=HELP_CONFIRM_MSG_ARGS_IE%>');
         else
              window.open('TSHead.Suggestions','','<%=HELP_CONFIRM_MSG_ARGS_NS%>');
         <%}%>
    It opens the window but when acted upon it say on a "Submit button" it again opens a window and hence looses the session values set upon login to the application.
    Is there any way to open a window in such a way that even when acted upon it through a submit button or cancel button doesnt give rise to new windows maintaining the session values?
    Valuable suggestions would be rewarded!!!
    -Thanks
    Padmarajan.

    Please watch Apple's Find Out How video series, here is the link to Finder basics, from this one you can locate all the others too:
    http://www.apple.com/findouthow/mac/#finderbasics

  • Command-tab between Terminal windows

    Hi, when I have multiple Terminal windows, I want to Command tab between these windows (like I can in Windows XP). However. the MacOS is treating the Terminal windows as one application. Anyone know how I can change this behaviour?
      Windows XP Pro  

    In Mac OS X, Command-Tab cycles only through applications. If you want to cycle through the open windows of a particular application, use the keystroke Command-`. This works for all applications that use multiple windows.
    For clarity, the (`) key is just above the Tab key, i.e. the one where tilde (~) is the uppercase character. Just hold down the Command key and hit ` to cycle through open Terminal windows.

  • Open Browser Window Text Link??

    Two questions:
    1) Can I make a text link use the open browser window function, if so how? Here is the attempt that has failed:
    <div class="style11" id="apDiv47" onfocus="MM_openBrWindow('BWPages/BW1002.html','','width=325,height=546')">#1002</div>
    2) How to properly code the open browser window function, so that when I use an image as the link the cursor becomes a hand instead of an arrow? Here is what I have:
    <img src="images/cards/Icons/card1002.jpg" alt="Motif_2" width="135" height="193" border="0" onclick="MM_openBrWindow('BWPages/BW1002.html','','width=325,height=546')" />
    Thanks much!

    Making Pop-Up Windows Using the Behaviors Panel in DW
    http://alt-web.blogspot.com/2010/02/making-pop-up-window-in-dreamweaver.html
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb
    http://alt-web.blogspot.com

  • [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)

  • 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.

  • 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 won't stop opening two windows.

    Every time I open Terminal, it opens two windows. One window has a bunch of text at the top that appears to be old commands(perhaps that I had typed? I don't remember all that I've typed into Terminal since the beginning of time ) in grey and then the normal Terminal prompt in the usual green(that's the theme I have) after all the text. The second window is in a fullscreen space thingy(Lion's mission control interface) and it looks similar except the text is different and there is a LOT more of it.
    I'm not quite sure what to do to make this stop. I've tried deleting the plist file for Terminal. I've tried restarting the computer. I've tried closing both windows, opeing a new one, positioning how I'd like it posistioned, then quitting Terminal by holding alt/option and cliking "Quit and Keep All Windows" from the Terminal menu.
    Is there a place where there are setting files for an app's window positions/defaults?
    It may also be good to mention, as it seems possibly relevant, that every time I open iPhoto, it opens in a fullscreen space much like the second Terminal window. I've tried similar things on iPhoto to get IT to stop doing this.
    Thanks for any help!

    Okay, so I actually found a solution to the problem!
    I cannot claim it as my own since I found it on another discussion page as well as CNET, but I'll post what I did here for others to see.
    The two helpful pages were:
    http://reviews.cnet.com/8301-13727_7-20083707-263/managing-mac-os-x-lions-applic ation-resume-feature/
    and
    https://discussions.apple.com/message/15859853#15859853
    What I did was:
    1. Enable "Restore windows when quitting and re-opening apps" under General in System Preferences(I don't know for sure if this is necessary, but it seemed harmless with my new found knowledge as you'll see in a moment)
    2. Navagate to "~/Library/Saved Application State/" in Finder
    3. Find the folder named "com.apple.Terminal.savedState"
    4. Move it to the trash
         This resets the state that the application uses to open each time it opens, when you open it now, it'll recreate the folder
    5. Launch Terminal
    6. Open the Get Info dialog for the newly created "com.apple.Terminal.savedState" and tick the "Lock" checkbox
         This prevents the contents of the folder from being changed, resultantly preventing ONLY Terminal from saving the state of it's windows on closing.
    Not only did this solve THIS problem, but it opened up some cool options:
    -By Locking any of these folders, one can keep a sort of template for how they'd like the windows of an application to open every time.
    -One can leave on the "Reopen windows" preference but select applications for which they do not wan't it to work. It is a semi useful feature, and I can understand why it was added, it just seems like an oversigt that it was only a global or no feature.
    -One can reset the window options of any trouble making apps in the future.
    Note: This also solved the problem I was having with iPhoto!

  • Terminal Window asking for password when opening

    I don't know what happens but everytime I open a terminal window its ask me for password. If I type my admin password it starts saying that can't found my ~ directory and starts in :/ instead of :~
    It is also showing ttys001 instead of 000 as usual.
    I don't know what it is, I think it have some relation with closing terminal windows without logging out of a ssh section, but I don't know how to resolve it. I tried reboot, "exit", delete com.apple.terminal
    Any sugestion?

    sgobin wrote:
    I don't know what happens but everytime I open a terminal window its ask me for password. If I type my admin password it starts saying that can't found my ~ directory and starts in :/ instead of :~
    It is also showing ttys001 instead of 000 as usual.
    I don't know what it is, I think it have some relation with closing terminal windows without logging out of a ssh section, but I don't know how to resolve it. I tried reboot, "exit", delete com.apple.terminal
    This is just a wild guess, but might there be a "sudo" command in a file in your home directory that's run when you launch a Terminal session, such as .bash_profile, .bash_login, or .profile? (This list assumes that you're using bash as your shell.)

Maybe you are looking for

  • How do I fix distorted photos in catalog?

    I went into PSE8 Editor and clicked Edit, Preferences, Editing and inadvertantly set settings to default. Now the photos are "stretched" vertically.  How can I fix this? Thanks,   Don

  • Best DVI to USB in 2011?

    I am a web programmer with a macbook pro. I have two monitors, one I can hook up via dvi, the other one I was thinking to hook up via dvi to usb. My concern is that one of my monitors is rotated 90 degrees, whereas the other one is sitting normally.

  • Cannot find a solution

    Have tried all the advice online and cannot get my firefox to work. It started off having issues tuning script. I could not type in the search bar. Got that fixed by reinstalling Now I can not access any site without it saying it is an untrusted site

  • XQuery many to one in an XML document ??

    I have XMLType tables with xml documents that have data like the sample below. There are one to many InvoiceLineRet to one InvoiceRet, how do I return this data in an XQuery? I have tried many iterations but cannot get data to return correctly. It is

  • Problem in activation of "Certify Completion" Button in LBK1.

    Hi Experts, We are working on LBK1 logbook entry. The Certify Completion Button in Notification is coming correctly, but in Log Entry this button is not displayed. How we can activate / display this button in LBK1 ? Study SAP