POV-Ray : Newsgroups : povray.general : File handles for output streams : Re: File handles for output streams Server Time
29 Jun 2025 13:11:40 EDT (-0400)
  Re: File handles for output streams  
From: William F Pokorny
Date: 19 Jun 2025 16:15:27
Message: <68546fdf$1@news.povray.org>
On 6/19/25 08:46, Chris R wrote:
> Am I missing something, or do I need to do some kludgy things to allow for both
> options?

For the record, and though it is in the "kludgy things" category, one 
can use some variation of the following example code on Unix/Linux:

//---
// this.pov
// Unix/Linux ways to write text to stdout stderr more directly.
// Method uses post_scene_command, so set [Shellout Security] to
// allowed in your povray.conf file.

#fopen FH_stdout "My_stdout_file" write
#fopen FH_stderr "My_stderr_file" write
#fclose FH_stdout
#fclose FH_stderr
#if (1)  // Set to 0 to empty the My_std* files
     #fopen FH_stdout "My_stdout_file" write
     #fopen FH_stderr "My_stderr_file" write
#else
     #fopen FH_stdout "/dev/null" append
     #fopen FH_stderr "/dev/null" append
#end


// Normal scene SDL work starts here
#version 3.8;
global_settings { assumed_gamma 1 }
background {rgb <1,1,0>}
// ...
#write(FH_stdout,"===> Hello stdout\n")
#write(FH_stderr,"===> Hello stderr\n")
// ...
// Normal scene SDL work ends here


#fclose FH_stdout
#fclose FH_stderr

// With yuqk and official povray the supporting ini command lines
// can be:
//
// post_scene_command="cat My_stdout_file >/dev/stdout;cat 
My_stderr_file >/dev/stderr"
//
// Run with:
//   yuqk this.pov include_ini=this.ini
// or
//  povray this.pov include_ini=this.ini
//
// With yuqk you can do it all on the command line too with the
// same ini style quoting here and usual Unix/Linux quoting otherwise.
// (Official POV-Ray cli quoting works too, but its form is strange)
//
// Run with, say:
// yuqk this.pov post_scene_command="cat My_stderr_file" >/dev/stderr
//
// To write meta data at the end of .ppm image output, for example -
// as the .ppm format allows appending text, you can then do
// something like:
//
// yuqk this.pov +fp post_scene_command="cat My_stderr_file" >>hmm.ppm
//
// given you've used FH_stderr for your image's user, meta data.
//
//---

Aside: This method a reason the yuqk fork has kept the +-hi / 
include_header= option and is considering an include_trailer= option. 
Also under consideration, are new user_ 'file handle' cli / ini options 
which would set up  some number of explicit user file handles for use 
with #write(). We'll see.

Bill P.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.