LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-09-2003, 03:43 AM   #1
Fe98
Member
 
Registered: Sep 2003
Distribution: RH9
Posts: 49

Rep: Reputation: 15
How do I save the output from a program?


I'm writing a program in C++ and one part of it has to use g++ and gcov. What command do I need in order to get the output from these programs? For example, if I run g++ on a file, how do I get the output (like error messages, if the file did not compile properly)?

Also, how do I call these programs from within a C++ program to begin with?
 
Old 11-09-2003, 07:44 AM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
to save output from a compile, for example a gcc compile:
Code:
gcc -o myfile myfile.c   >output.lis  2>errorlisting.lis
output.lis has what was displayed on stdout
errorlisting.lis has what was displayed on stderr - the error information
 
Old 11-09-2003, 12:52 PM   #3
Fe98
Member
 
Registered: Sep 2003
Distribution: RH9
Posts: 49

Original Poster
Rep: Reputation: 15
Ok cool, thanks.
 
Old 11-09-2003, 09:46 PM   #4
Fe98
Member
 
Registered: Sep 2003
Distribution: RH9
Posts: 49

Original Poster
Rep: Reputation: 15
Another question though, if the files (output.lis and errorlisting.lis) are both 0 bytes, does this mean that everything was successful? (It seems so, but I want to make sure)
 
Old 11-10-2003, 10:18 AM   #5
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
Check

Code:
echo $?
- the return code from the script - it should be zero ( 0 ) if everything was fine.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Screen Listing Output Save in a File rolly frando Linux - Newbie 3 07-04-2005 02:23 AM
where does a linux program save it's settings? Cinematography Linux - Software 16 05-14-2005 03:30 AM
C function to execute a program and return the output of the program ryan.n Programming 4 08-14-2004 11:11 PM
PHP: save output to a file mikeshn Programming 2 10-25-2003 07:57 AM
OpenOffice save button hangs program bobterri Linux - Software 8 01-23-2003 02:39 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration