Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 73455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:12:15+00:00 2026-05-10T20:12:15+00:00

How do I launch an app and capture the output via stdout and maybe

  • 0

How do I launch an app and capture the output via stdout and maybe stderr?

I am writing an automated build system and I need to capture the output to analyze. I’d like to update the svn repo and grab the revision number so I can move the files in autobuild/revNumber/ if successful. I also would like to build using make and upload the compile text to my server for everyone to see the warnings and errors on a failed build.

I can’t find the system() function, but I found the CreateProcess() function on MSDN. I am able to launch what I need but I have no idea how to capture the stderr and stdout. I notice the process launches separately unless I set a breakpoint and keep my app exiting which it then will keep all the text in my app console window. I would also want to wait until all processes are finished and then scan the data it produced to do any additional operations I need. How do I do any of this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:12:16+00:00Added an answer on May 10, 2026 at 8:12 pm

    In real shells (meaning, not sea shells – I mean, not in C Shell or its derivatives), then:

    program arg1 arg2 >/tmp/log.file 2>&1 

    This runs program with the given arguments, and redirects the stdout to /tmp/log.file; the notation (hieroglyph) ‘2>&1‘ at the end sends stderr (file descriptor 2) to the same place that stdout (file descriptor 1) is going. Note that the sequence of operations is important; if you reverse them, then standard error will go to where standard output was going, and then standard output (but not standard error) will be redirected to the file.

    The choice of file name shown is abysmal for numerous reasons – you should allow the user to choose the directory, and probably should include the process ID or time stamp in the file name.

    LOG=${TMPDIR:-/tmp}/log.$$.$(date +%Y%m%d-%H%M%S) program arg1 arg2 >$LOG 2>&1 

    In C++, you can use the system() function (inherited from C) to run processes. If you need to know the file name in the C++ program (plausible), then generate the name in the program (strftime() is your friend) and create the command string with that file name. (Strictly, you also need getenv() to get $TMPDIR, and the POSIX function getpid() to get the process ID, and then you can simulate the two-line shell script (though the PID used would be of the C++ program, not the launched shell).

    You could instead use the POSIX popen() function; you’d have to include the ‘2>&1‘ notation in the command string that you create to send the standard error of the command to the same place as standard output goes, but you would not need a temporary file:

    FILE *pp = popen('program arg1 arg2 2>&1', 'r'); 

    You can then read off the file stream. I’m not sure whether there’s a clean way to map a C file stream into a C++ istream; there probably is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to launch an app on OSX from a script. I need to
I create and launch an app like this: express -s -t ejs npm install
First, I launch the camera app to capture picture. Once it is done, I
Before doing a openUrl: to launch an app that should callback my app (like
Other than for app launch shortcuts, which should only be provided by the O/S,
I want to launch my app in landscape mode and I am following the
When I launch my app on iOS 5.1, on a device (only tested on
At the moment when i use this, i have to re-launch the app to
I'm soon to launch a beta app and this have the option to create
After the first launch of my app i want to show the user a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.