Reading console output from external executable (fxc)

Started by
13 comments, last by NightCreature83 11 years, 1 month ago

So what 2>&1 does is redirect the output of stderr (being 2) to the stdout (being 1) ?

Is there also a way to check when it is done compiling before I execute the _pclose() function ?

Yes.

Sorry, just saw the second part.

Check your file pointer against feof(test) before using it. Something like:


while( !feof(test) )
{
   ...
}
Advertisement

Great. Thanks a lot.

Just tried doing that before reading. Still nothing. When running it the console window pops up and closes right after.

edit: There's something written about how to read the error's and output here (bottom of the page) http://msdn.microsoft.com/en-us/library/windows/desktop/bb509710(v=vs.85).aspx but they state nowhere what "hReadOutPipe" or "hReadErrorPipe" is or how it was created.

@Cosmic314 I know but it still outputs an error that states that which is the reason why I want to read its output in the first place.

You realise that MS code heftly relies upon hungarian code standard so the lowercase h in front of the vars should be a hint to you that these are Handles. The handles come from the call to CreateProcess and actually are returned to you through the STARTUPINFO structure that comes out of the CreateProcess call.

Reading documentation is also a skill and the MS ones are not easy but once you do get used to them the actually do tell you everything you need to know. All I did to figure out where the handles where coming from was to go to the CreateProcess documentation page and from there to the STARTUPINFO documentation. That together with the names of the handles made me realise they should map to HANDLE hStdOutput; HANDLE hStdError; that are in the startup info.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion

I do realize that they were handles to the standard outputs, it's just that I had no idea how they work or how I create "NamedPipes"...I guess I did not check up on the STARTUPINFO documentation. But I guess you have to realize that some people with less experience than you can't figure that out in a matter of seconds.
And I did not feel like wasting an hour figuring out how this system works.
Anyway I've got it working now using the previous solution.

Yeah the post might have read hostile after rereading I didn't mean it that way though. All I meant is that reading MS docs is a skill and you will have to learn how to do this, they contain a lot of information and not always in the clearest manner. I found the most important bits to read on those are always the remarks as they most likely explain why something isn't working, and other then that it is an exercise in reading and understanding what you read.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion

This topic is closed to new replies.

Advertisement