Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output of a command to a file 1

Status
Not open for further replies.

stevenk140

Programmer
Nov 20, 2003
34
CA
I have a problem where from my c program, I am running a system command with:

system(cmd);

Now I have a couple of problems. The program I am running in that command is failing and I want to catch the stderr output (so a 'cmd > outfile' does not work). How could I output the results of my command to a file?


Steve
 
Well depending on how capable your shell is, the following should work
Code:
system("cmd 2>err");

Works on unix shells and win2k/XP consoles
Won't work on DOS/Win9x command lines


--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top