Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch copy across network with failure log  (Read 6090 times)

0 Members and 1 Guest are viewing this topic.

DrVal

  • Guest
Batch copy across network with failure log
« on: June 23, 2008, 10:32:08 AM »
I'll just post this while I try to find the answer in the past posts...

I'm trying to copy some root folders off one networked drive and copy them onto a local drive on a server.
The kicker is I want it to run automatically and inform me of any errors.
I found XXCopy, which will do this, but requires you to purchase a pro version or hit a button if it's on a networked drive, so it's paused until I hit a button. I get output to a log file that looks like this:

Code: [Select]
\\SERVER2, a server (networked computer) is being accessed.

You have the XXCOPY Freeware version for a stand-alone computer.
If you access the remote disk on a regular basis, you may consider
acquiring a license for XXCOPY-PRO license (for 2 computers).
Press any key to continue . . .

-------------------------------------------------------------------------------
F:\055-244010.OLD\proj\sct10maj\lots\sct10maj.gcf                           162
F:\055-244010.OLD\proj\sct10maj\zz\aaa.doc                          Copy failed
F:\055-244010.OLD\proj\sct10maj\zz\locale.dat                               830

But when I use typical XCopy, it doesn't log that the file failed to copy, it puts in the Command window that called it so it looks like this:

Code: [Select]
F:\055-244010.OLD\proj\sct10maj\lots\sct10maj.gcf
F:\055-244010.OLD\proj\sct10maj\zz\aaa.doc
F:\055-244010.OLD\proj\sct10maj\zz\locale.dat
F:\055-244010.OLD\proj\sct10maj\zz\Test.dat
868 File(s) copied
And the command window looks like this:
Code: [Select]
C:\>testy.bat > c:\log.txt
Access denied
C:\
(Note, I have a test file in there, aaa.doc that I don't have permissions to so I can test the errors)
So you can see how it doesn't tell me that aaa.doc had an error, just a list of errors in the command prompt - seems silly to me...

My question is two fold:

A) Is there a way to log XCopy's failures and which file it failed on?
B) Is there a way to emulate a keypress so I can get past XXCopy's complaints and still keep it logged properly so I can ensure the integrity of my backup?

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Batch copy across network with failure log
« Reply #1 on: June 23, 2008, 01:44:44 PM »
Quote
Is there a way to log XCopy's failures and which file it failed on?

Output usually consists of two output streams (1-STDOUT and 2-STDERR) which can be redirected together or separately. The default is the console.

xcopy parms >good.log 2>bad.log
    each stream goes to separate files

OR

xcopy parms 2>bad.log
    one stream to console; errors to file

OR

xcopy parms  2> both.log 1>&2
    both streams to same output file


Quote
Is there a way to emulate a keypress so I can get past XXCopy's complaints and still keep it logged properly so I can ensure the integrity of my backup?

You might be able to pipe the enter key into xxcopy:

echo. | xxcopy parms

Not all programs can accept input from the pipe, but hey, you never know.

Good luck. 8)

The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

nothlit



    Intermediate

    Thanked: 2
    Re: Batch copy across network with failure log
    « Reply #2 on: July 14, 2008, 03:31:11 PM »
    I think I have a similar request to the lines of this.

    I want to output the copied files to a file, I can do that by typing >>%log% at the end of the command, but if there is a user prompt ....

    Does \\Server\directory\Forms specify a file name
    or directory name on the target
    (F = file, D = directory)?

    Is there a way to keep everything in the log and directory it to the console so the user can enter D for directory, or better yet of course have it automate. Dos is pretty much my only option at this time. If too off topic I will open a new topic. Thanks for your help.

    nothlit



      Intermediate

      Thanked: 2
      Re: Batch copy across network with failure log
      « Reply #3 on: July 14, 2008, 03:34:31 PM »
      Now that I'm thinking about this a little more I think I figured it out. I can push everything to the log, then before the coping of the directory just make the directory first assuming I know its name which in this case I do.

      Now for future reference if I didn't how could I handle this?

      Sidewinder



        Guru

        Thanked: 139
      • Experience: Familiar
      • OS: Windows 10
      Re: Batch copy across network with failure log
      « Reply #4 on: July 14, 2008, 04:12:54 PM »
      While the literal from a prompt may end up in the log, there is still an interrupt pending on the console. Provided you know the actual prompt, you can pump in the response:

      echo D | xcopy source target >> log.txt

      OR

      echo F | xcopy source target >> log.txt

      For programs that require multiple responses you can create a sequential response file and redirect the STDIN data stream:

      xcopy source target  1>log.txt 0<resp.txt

      The resp.txt file might contain:

      D
      Y

      which will cover the situation when XCOPY first asks about files/directories and then requests your permission for overwrites.

      Good luck. 8)

      « Last Edit: July 14, 2008, 04:37:48 PM by Sidewinder »
      The true sign of intelligence is not knowledge but imagination.

      -- Albert Einstein

      nothlit



        Intermediate

        Thanked: 2
        Re: Batch copy across network with failure log
        « Reply #5 on: July 16, 2008, 10:44:20 AM »
        Thank you for that, It worked. :)

        Spoiler



          Specialist

          Thanked: 50
        • Experience: Beginner
        • OS: Windows XP
        Re: Batch copy across network with failure log
        « Reply #6 on: July 16, 2008, 10:49:06 AM »
        You can also try Syncback. I use it on my servers to backup files across machines.

        http://www.2brightsparks.com/syncback/sbse-features.html

        it works great and even creates a HTML log.

        Whenever I watch TV and I see those poor starving kids all over the world, I can't help but cry. I mean I would love to be skinny like that, but not with all those flies and death and stuff." - Mariah Carey, Pop Singer