Solved

Redirection to screen and file

Posted on 2004-04-27
8
2,093 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

 

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

730 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