?
Solved

Pipe output to a file with a batch file

Posted on 2007-12-04
4
Medium Priority
?
6,375 Views
Last Modified: 2010-01-12
I am setting up a batch job that will transfer files to several machines.  How do i send the output to a file so i can tell if any machines got missed?

i would echo the machine name, then i need to send the output of if it copied or not after it.
0
Comment
Question by:Fraser_Admin
[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
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
weareit earned 1000 total points
ID: 20404199
you can use the > charactor to redirect the output to a file.

> will overwrite
>> will append

i.e.

echo Todays date is > date.txt
date >> date.txt

-saige-
0
 
LVL 4

Assisted Solution

by:gabbadar
gabbadar earned 1000 total points
ID: 20404276
You can send the output of any command to file using the > or >> characters:
> - will create a new file
>> - will append to an existing file (or create if non existent)

So this would be a good start:




Echo Server1 >> c:\CopyLog.txt
xcopy \\server1\share\* \\my\destination >>c:\CopyLog.txt
Echo ---------- >> c:\CopyLog.txt
Echo Server2 >> c:\CopyLog.txt
xcopy \\server2\share\* \\my\destination >>c:\CopyLog.txt

Open in new window

0
 

Author Comment

by:Fraser_Admin
ID: 20404783
how do i send the date.  when i do date > output.txt it waits for me to press enter.  i also want to have the date/time combination?
0
 
LVL 4

Expert Comment

by:gabbadar
ID: 20405520
Rather than use the date/time program, use the variables:

echo %date% - %time%
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month11 days, 3 hours left to enroll

770 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