I run an interactive JAVA program on the DOS prompt and want to be able to save the whole interaction in a txt file.
Is there a way to achieve it ?
I run a batch file like this
C:\> runbatch.bat
which contains the following command
C:\> Java ABC
This program will ask some questions from the user then do some processing. How to I spool everything from from the java programs output ?
All help is appreciated.
regards
SKT
Spool an interactive JAVA program ?
Moderator: DosItHelp
Re: Spool an interactive JAVA program ?
Major Edit: OOPS! I missed the key word interactive. My "solution" below in black will not work since you won't be able to see or respond to the prompts.
You need something like the Unix tee command - it sends stdout to the console and to a file.
I have a version of tee for Windows, but I don't remember where it came from. Search the internet for free unix utilities for Windows.
----------------
To simply capture stdout into a file use:
This will overwrite any existing test.txt file
If you want to preserve the existing test.txt and append the results to it, then use:
Note that the above only captures stdout, not stderr. Error messages will not be captured if they are written to stderr.
If you want to capture both stdout and stderr:
or using append
Dave Benham
You need something like the Unix tee command - it sends stdout to the console and to a file.
I have a version of tee for Windows, but I don't remember where it came from. Search the internet for free unix utilities for Windows.
----------------
To simply capture stdout into a file use:
Code: Select all
Java ABC >test.txt
If you want to preserve the existing test.txt and append the results to it, then use:
Code: Select all
Java ABC >>test.txt
Note that the above only captures stdout, not stderr. Error messages will not be captured if they are written to stderr.
If you want to capture both stdout and stderr:
Code: Select all
Java ABC >test.txt 2>&1
or using append
Code: Select all
Java ABC >>test.txt 2>&1
Dave Benham
Re: Spool an interactive JAVA program ?
thanks dave, I did download one tee utility but that hangs. i think i will search more until i find one.
regards
skt
regards
skt