in reply to WIN redirecting STDOUT and STDIN to new spawned CMD console

What if you redirect stdout to a temp file and then launch a separate perl program whose only job is to monitor this temp file and see if it changes. And if it does change, it reads the last 25 lines from the file and prints it to this terminal window. That way whatever gets written to stdout will be displayed in the terminal window.
  • Comment on Re: WIN redirecting STDOUT and STDIN to new spawned CMD console

Replies are listed 'Best First'.
Re^2: WIN redirecting STDOUT and STDIN to new spawned CMD console
by soonix (Chancellor) on Mar 29, 2023 at 06:26 UTC
    That would be a *very* roundabout fashion, but might achieve the goal. Perhaps better with a named pipe instead of a temp file...
      > would be a very roundabout fashion

      Well with variations it's just a classic.

      You start a second console running the application redirecting STDERR to a log file. The first console does a tail -f on the log-file

      With PowerShell in the first window at least that's technically feasible, it has a tail like mechanism. °

      > Perhaps better with a named pipe

      Not sure how hard it is to have named pipes on windows.

      Cheers Rolf
      (addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
      Wikisyntax for the Monastery

      updates

      °) Get-Content -Path ".\err.log" -Wait