Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Redirection of XCOPY error messages

168 views
Skip to first unread message

Mick Flynn

unread,
Feb 10, 1998, 3:00:00 AM2/10/98
to

All,

I'm currently writing a batch in Win95 to perform backups using XCOPY. All
output gets redirected to a backup.log file.

Everything's fine EXCEPT that the error messages from XCOPY (e.g. cannot
copy emm386.swp (as it is always in use)) go straight to the screen instead
of to the log file, defeating the purpose somewhat.

My guess is that (in UNIX terms) while XCOPY outputs the normal output
(=files copied) to standard out, it outputs errors to standard error. The
problem is that I don't know how to redirect (or otherwise access) standard
error in DOS.

Is there a way to redirect these errors somewhere else that CON?

Thanks,

Mick Flynn
mick....@kltdata.se


Tom Lavedas

unread,
Feb 10, 1998, 3:00:00 AM2/10/98
to Mick Flynn

Redirecting the standard error in DOS, other than to the NUL device is a
tricky business. The standard approach to quieting the error responses
is to use a CTTY NUL before the ofending command and a CTTY CON after,
something like ...

ctty nul
xcopy whatever someplace
ctty con

I seem to remember reading somewhere that CTTY is not part of the Win NT
command processor (CMD.COM), but that a version of COMMAND.COM is
supplied with NT that should supply this function.

CTTY can be used to redirect the CONsole to any other standard device,
but not to a file. There are third party utilities that will redirect
devices into files, chief among these is the venerable PC Mag utility,
PRN2FILE.COM. It is widely available at the standard PC utility ftp
sites. With PRN2FILE, everything, except direct writes to the video
text
buffer, can be redirected to a file something like ...

prn2file lpt3 output.txt
ctty lpt3
xcopy whatever someplace
ctty con
prn2file lpt3

It's been a long time since I have used PRN2FILE. Check the
documentation that should come with it for the exact syntax for
PRN2FILE.

Tom Lavedas
-----------
Delta Electronics, Inc.
http://www.deltaelectronics.com/tglbatch/

Martin Whittaker

unread,
Feb 10, 1998, 3:00:00 AM2/10/98
to


Just hope that nothing goes wrong while CTTY is active. There's no way
out except Reset or BRS (BRS=Big Red Switch).


//Martin * mart...@sky.net * <-reply:

Mike A. Schwab

unread,
Feb 11, 1998, 3:00:00 AM2/11/98
to Mick Flynn

Try '2>C:\part\xcopyerr.txt' or '2>>C:\path\xcopyerr.txt'.

Mick Flynn wrote:
>
> All,
>
> I'm currently writing a batch in Win95 to perform backups using XCOPY. All
> output gets redirected to a backup.log file.
>
> Everything's fine EXCEPT that the error messages from XCOPY (e.g. cannot
> copy emm386.swp (as it is always in use)) go straight to the screen instead
> of to the log file, defeating the purpose somewhat.
>
> My guess is that (in UNIX terms) while XCOPY outputs the normal output
> (=files copied) to standard out, it outputs errors to standard error. The
> problem is that I don't know how to redirect (or otherwise access) standard
> error in DOS.
>
> Is there a way to redirect these errors somewhere else that CON?
>

> Thanks,
>
> Mick Flynn
> mick....@kltdata.se

Brian Kurtz

unread,
Feb 11, 1998, 3:00:00 AM2/11/98
to

Mick Flynn wrote:
> Is there a way to redirect these errors somewhere else that CON?

Using printer redirection and console echo to printer enabled...
DOS will echo each command to the printer as it executes and all
of its output including error messages whenever enabled.
Console echo-to-the-printer is enabled by pressing CTRL-P
on the keyboard. Output is sent to the PRN device. To enable
this action programmatically requires the use of an undocumented
DOS INT 21H function 34H. The byte value at address ES:[BX-23H] is
zero if printer echo is disabled or 255 if printer echo is enabled.
You can create PRNON and PRNOFF commands using DEBUG...

-----------
DEBUG
nprnon.com
a
mov ah,34
int 21
es:
mov by [bx-23],FF
mov ax,4c00
int 21

rcx
10
w
nprnoff.com
a
mov ah,34
int 21
es:
mov by [bx-23],00
mov ax,4c00
int 21

rcx
10
w
q
------

Once the output is at the PRN device, use PRN2FILE utility
to redirect the PRN device to a file.

PC Magazine utility to redirect a printer port to a file
ftp://garbo.uwasa.fi/pc/pcmagutl/prn2file.zip

Usage: PRN2FILE [path][filename][/Pn][/Bnn][/U]

-------
Now, by using these tools, you can capture all messaging to a file.

prn2file xcopy.out
prnon
xcopy ...
prnoff
prn2file /u

Now, develop a tool to search the files for errors!
..so you won't have to! The FIND command will work
on a limited basis for a few search keys but, it
fails when searching multi-megabyte files - too slow!

Enjoy!

--
-bk- <mailto:bku...@bellsouth.net>

Mick Flynn

unread,
Feb 11, 1998, 3:00:00 AM2/11/98
to

Mike,

Sorry, already tried that. DOS interprets the 2 as a filename or command
line argument. For once it seems MS didn't go far enough when plagiarising
other systems :-)

Mick


Mike A. Schwab wrote in message <34E1453C...@WAMUSA.com>...


>Try '2>C:\part\xcopyerr.txt' or '2>>C:\path\xcopyerr.txt'.
>
>Mick Flynn wrote:
>>
>> All,
>>
>> I'm currently writing a batch in Win95 to perform backups using XCOPY.
All
>> output gets redirected to a backup.log file.
>>
>> Everything's fine EXCEPT that the error messages from XCOPY (e.g. cannot
>> copy emm386.swp (as it is always in use)) go straight to the screen
instead
>> of to the log file, defeating the purpose somewhat.
>>
>> My guess is that (in UNIX terms) while XCOPY outputs the normal output
>> (=files copied) to standard out, it outputs errors to standard error.
The
>> problem is that I don't know how to redirect (or otherwise access)
standard
>> error in DOS.
>>

>> Is there a way to redirect these errors somewhere else that CON?
>>

>> Thanks,
>>
>> Mick Flynn
>> mick....@kltdata.se

0 new messages