Computing.Net > Forums > Disk Operating System > DOS redirect

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

DOS redirect

Reply to Message Icon

Name: RGHC
Date: August 3, 2001 at 16:32:59 Pacific
Comment:

I am looking to redirect output from a batch file
to BOTH the screen and a file.
Currently I use "doit.bat > test.txt",
but don't get the screen output.

Robert...



Sponsored Link
Ads by Google

Response Number 1
Name: jboy
Date: August 3, 2001 at 18:10:49 Pacific
Reply:

... and you won't.
Batch files themselves can't be redirected, only commands (and not all of them). Possibly, you could redirect a command's output on a line IN the BAT file.


0

Response Number 2
Name: hmmmm
Date: August 3, 2001 at 19:50:57 Pacific
Reply:

Currently I use "doit.bat > test.txt",
ok! now just add

doit.bat > test.txt
type test.txt |more

The input will go to test.txt
The next line will display it.
Depending on the size you may not need the
pipe more command.

hmmmm

Not much of a name, I know.I am just watching over the World Library machines and kids.Love playing with their connection as it goes anywhere. http,ftp,irc,icq,and has thousands of news groups.

Found the answer in the Library. Hope it is the right one for the problem.


0

Response Number 3
Name: jboy
Date: August 3, 2001 at 20:05:08 Pacific
Reply:

That would work just fine.... except with a batch file.
Yes, at first that's what I thought the question was - how to get the screen output AND log to a .txt file.
Can't redirect a batch file in this manner - try it, and test.txt WILL be generated... but it's an empty (zero length) file.


0

Response Number 4
Name: Mike
Date: November 21, 2001 at 02:45:07 Pacific
Reply:

I got the following to work by redirecting the output from within the dos batch file as previously suggested.

REM This is a batch file to make bkups of
REM directories c:\dir1 and c:\dir2.

xcopy c:\dir1\* c:\bkup\dir1 /s > log.txt
xcopy c:\dir2\* c:\bkup\dir2 /s >> log.txt

REM The first right arrow ">" places the.........
REM screen output from the first xcopy into...... REM log.txt. If log.txt does not exist it is..... REM created. If log.txt does exist it is......... REM replaced.....................................
REM The double arrow ">>" on the second..........
REM xcopy appends/adds the output to log.txt .... REM after the output already in log.txt from .... REM the first xcopy.



0

Response Number 5
Name: Mike
Date: November 21, 2001 at 03:00:46 Pacific
Reply:

Sorry about the bad appearance above. Let me try this again....

I got the following to work by redirecting the output from within the dos batch file as previously suggested.


This is a batch file to make bkups of
directories c:\dir1 and c:\dir2.

xcopy c:\dir1\* c:\bkup\dir1 /s > log.txt
xcopy c:\dir2\* c:\bkup\dir2 /s >> log.txt

The first right arrow ">" places the screen output from the first xcopy into log.txt.
If log.txt does not exist it is created.
If log.txt does exist it is replaced.
The double arrow ">>" on the second
xcopy appends/adds the output to log.txt.
Now log.txt contains screen output from
the first xcopy followed by screen output
from the second xcopy.


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: DOS redirect

DOS Redirection www.computing.net/answers/dos/dos-redirection/11763.html

DOS redirect for DEL command www.computing.net/answers/dos/dos-redirect-for-del-command/12947.html

DOS Redirect LPT1: to LPTn: www.computing.net/answers/dos/dos-redirect-lpt1-to-lptn/7143.html