Redirection to screen and file

i need to redirect o/p to the screen and to the file simaltaneously.(DOS)
the reason for this is that i'm running a ftp session and I want it to be captured to a log file. simaltaneously as the program is run i need some input from the user. If i redirect the output to the log file with ">" operator then there is nothing shown on the screen. The dos I use is the one with XP (cmd)

Thanks in advance
Francois Pelletier
Who is Participating?
brianadkinsConnect With a Mentor Commented:

There is a utility called TEE that will redirect to both:

You only get one output device. However, at less than real time, if you first write to log file, or temp file, you can then display content of logfile to the screen. In synchronization but not simultaneously, although it should appear just as well to human. With batch file, you can even have the initial proggie write one line of output, then read it in to display on screen, then write it out to a larger file for accumulation of lines if you want. Crude Shorthand:

Echo "a line" > temp
Type temp
Type temp >> log
Hmm- yes, not simultaneous, but close....
Provide a little more detail on this and someone might be able to narrow it down for you.

I'm thinking something like this would generate a narrower range between the output writes though:
for instance, if I want to display a directory of c:\windows\inf:

for /f %%a in ('dir %windir%\inf') do echo %%a >> results.txt
Now, my results.txt file will contain my results, as well as my seeing them on screen...
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Francois_PAuthor Commented:
But my problem is not related to a DIR command, I use the FTP command and need the user to interact with it, so I need the FTP command to print the output to the screen live while the session is running, but I also need the output to be redirected to a file to log the result of the session.
TEE seems to work fine here.  I am able to perform an interactive FTP session (browse and get files) and all the text is captured in the log file.

Francois_PAuthor Commented:
Thank Brian, but is there a way to do it without installing a utility. Or is this the only way you know?
Thanks in advance for the answer

You don't really need to "install" anything... just treat tee.exe like an external DOS command.  (Just make sure it's in your path and you should be good to go)

There are a lot of extra 'utility' files that are not availble in DOS , but that are great additions to DOS.  Microsoft's ROBOCOPY is another good example.

Others "must-haves" in my opinion:
PSTools (
Unixutils (
NT Resource Kit utiliies
command-line PKZip tools

Francois_P - I used DIR as an example.
Is your FTP session automated using FTP -s:myscript.ftp (example)
If not, then the tool Brian's recommended would be the only option for you...
Otherwise, enclose the ftp commands within the paren in my prior example.
All Courses

From novice to tech pro — start learning today.