Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Cosmic314

Member Since 25 Jul 2003
Offline Last Active Yesterday, 07:48 AM
-----

#5044585 Reading console output from external executable (fxc)

Posted by Cosmic314 on 19 March 2013 - 09:09 AM

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) )
{
   ...
}



#5044583 Reading console output from external executable (fxc)

Posted by Cosmic314 on 19 March 2013 - 09:04 AM

Hmm it's odd I just tried it with another console application, where it works. Running fxc.exe does not give me any output though...

@Cosmic314 So the text that it outputs in the cmd.exe is not the standard output ?

It all depends on how fxc.exe writes its messages.  It sounds like it opens both STDOUT and STDERR which is typical in console applications (I'm in Linux land and that's standard fare).  I'm guessing fxc.exe does just this and when it encounters errors it spits it out to STDERR.

 

The reason for this is to easily separate errors from expected output.  Instead of using 2>&1 you could instead do 2> file.txt and the STDERR stream would go to a file instead.




#5044579 Reading console output from external executable (fxc)

Posted by Cosmic314 on 19 March 2013 - 08:55 AM

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

 

_popen only opens the process' standard output.  If you need to read stderr redirect it to stdout via:  FILE *test = _popen("fxc.exe <your_options> 2>&1","r");  

 

'stderr' is represented by the 2 file descriptor hence the "2>&1".

 

Edit:  Sorry, forgot to add "2>&1".




#5044576 Reading console output from external executable (fxc)

Posted by Cosmic314 on 19 March 2013 - 08:47 AM

Do you specify the full path to the input file?  Maybe your program is running in a different directory than your input source?




#5044570 Reading console output from external executable (fxc)

Posted by Cosmic314 on 19 March 2013 - 08:29 AM

Does fxc.exe buffer its output?  Use the function fflush(test) to empty the buffer to the OS.

 

Edit:  You'll also need to provide input to fxc.exe.  Your _popen should be something like FILE *test = _popen("fxc.exe <shader_input_file>","r");




#5044562 problem with perl input

Posted by Cosmic314 on 19 March 2013 - 07:59 AM

In Windows there is no '-k' option for your sort system call.  Sort interprets '-k' as the name of a file.  Since you specify it twice this is why you get the error.




PARTNERS