Solved

Redirection to screen and file

Posted on 2004-04-27
8
2,086 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
 

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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now