Reading STDIN and Writing to STDOUT
Keywords: STDIN STDOUT
Question:
How do I write to standard output? In other words, just print output to the DOS window (you know, like a dir cmd that simply lists all the files to the screen). I also want to make sure it's to STANDARD output so it can be piped, redirected, etc.I'm just a little surprised that I can't use the fileopen on the (what is it - 5?) std files. Apparently from what I've seen here, it DOES work with LPT, COM, etc. I would have thought it should have worked with the others as well.
Answer:
No way to easily write to stdout or read from stdin. But here are some workarounds for strdout/stdin.
- For stdin, pipe the data to a file. Then Winbatch can read the file
- for stdout, make sure WinBatch is started with the start /w switch. Have Winbatch write to a file. Then in the BAT file TYPE the file to move it to stdout.
- For interpreted/compiled:
Look into the rtstatus() function.
a=rtstatus() Message("A is",a)
Article ID: W14221Filename: Reading Stdin and Writing to Stdout.txt