Solved

Redirection to screen and file

Posted on 2004-04-27
8
2,091 Views
Last Modified: 2008-03-03
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
0
Comment
Question by:Francois_P
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 24

Expert Comment

by:SunBow
ID: 10928923
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
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 10929033
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...
0
 
LVL 5

Accepted Solution

by:
brianadkins earned 500 total points
ID: 10929279

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

http://www.csc.calpoly.edu/~bfriesen/software/console.shtml

-Brian
0
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

Author Comment

by:Francois_P
ID: 10929326
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.
0
 
LVL 5

Expert Comment

by:brianadkins
ID: 10929379
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.

-Brian
0
 

Author Comment

by:Francois_P
ID: 10929396
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
0
 
LVL 5

Expert Comment

by:brianadkins
ID: 10929577

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:
=================
tee.com
PSTools (www.sysinternals.com)
Unixutils (unxutils.sourceforge.net)
NT Resource Kit utiliies
command-line PKZip tools

-Brian
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 10929595
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.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question