[Toc][Index]

How to check if STDIN, STDOUT or STDERR are redirected to a file



To check, if STDIN, STDOUT or STDERR are redirected to a file use the 
following code: 

 
/* This code works in Object-Oriented REXX only!                      */

  STDIN_type = stream( 'STDIN', 'c', 'QUERY STREAMTYPE' )
  if STDIN_type = "PERSISTENT" then
    say "STDIN is redirected to a file."
  else
    say "STDIN is the screen or a pipe or NUL."

  STDOUT_type = stream( 'STDOUT', 'c', 'QUERY STREAMTYPE' )
  if stdout_type = "PERSISTENT" then
    say "STDOUT is redirected to a file."
  else
    say "STDOUT is the screen or a pipe or NUL."

  STDERR_type = stream( 'STDERR', 'c', 'QUERY STREAMTYPE' )
  if stderr_type = "PERSISTENT" then
    say "STDERR is redirected to a file NUL."
  else
    say "STDERR is the screen or a pipe."

  

Created using Inf-PHP v.2 (c) 2003 Yuri Prokushev
Created using Inf-HTML v.0.9b (c) 1995 Peter Childs