Solved

Pipe output to file under Command Prompt

Posted on 2011-10-04
758 Views
Windows experts

I am able to pipe output to file using > or append next output with >> . But all outputs are mixing up. so I like to put some word before the next output. Please see what I like to achieve.

Now :

exclude = C:\Program Files\Veritas\NetBackup\bin\*.lock
exclude = C:\Program Files\Veritas\NetBackup\bin\bprd.d\*.lock
exclude = C:\Program Files\Veritas\NetBackup\bin\bpsched.d\*.lock
exclude = C:\Program Files\Veritas\NetBackupDB\data\*
exclude = C:\Program Files\Veritas\Volmgr\misc\*
exclude = C:\WINDOWS\system32\config\AppEvent.Evt
exclude = C:\WINDOWS\system32\config\SecEvent.Evt
exclude = C:\WINDOWS\system32\config\SysEvent.Evt
exclude = C:\Program Files\Veritas\NetBackup\bin\*.lock
exclude = C:\Program Files\Veritas\NetBackup\bin\bprd.d\*.lock
exclude = C:\Program Files\Veritas\NetBackup\bin\bpsched.d\*.lock
exclude = C:\Program Files\Veritas\NetBackupDB\data\*
exclude = C:\Program Files\Veritas\Volmgr\misc\*
exclude = C:\WINDOWS\system32\config\AppEvent.Evt
exclude = C:\WINDOWS\system32\config\SecEvent.Evt
exclude = C:\WINDOWS\system32\config\SysEvent.Evt

I WANT  LIKE THIS:

ACCTS
exclude = C:\Program Files\Veritas\NetBackup\bin\*.lock
exclude = C:\Program Files\Veritas\NetBackup\bin\bprd.d\*.lock
exclude = C:\Program Files\Veritas\NetBackup\bin\bpsched.d\*.lock
exclude = C:\Program Files\Veritas\NetBackupDB\data\*
exclude = C:\Program Files\Veritas\Volmgr\misc\*
exclude = C:\WINDOWS\system32\config\AppEvent.Evt
exclude = C:\WINDOWS\system32\config\SecEvent.Evt
exclude = C:\WINDOWS\system32\config\SysEvent.Evt
BAGSALE
exclude = C:\Program Files\Veritas\NetBackup\bin\*.lock
exclude = C:\Program Files\Veritas\NetBackup\bin\bprd.d\*.lock
exclude = C:\Program Files\Veritas\NetBackup\bin\bpsched.d\*.lock
exclude = C:\Program Files\Veritas\NetBackupDB\data\*
exclude = C:\Program Files\Veritas\Volmgr\misc\*
exclude = C:\WINDOWS\system32\config\AppEvent.Evt
exclude = C:\WINDOWS\system32\config\SecEvent.Evt
exclude = C:\WINDOWS\system32\config\SysEvent.Evt

So When I copy all outputs once from file , So I may recognize know what output belong to which server.
Thanks!
0
Question by:MSGK161091

LVL 51

Expert Comment

How is the output being generated, is it one piece at a time, or all at once.  If in pieces, then you can add your breaks when needed by doing:

echo BAGSALE >> logfile.txt

If all the lines are written at the same time from a single command or program, then you would need to define some rules about where the breaks are inserted.

~bp
0

LVL 1

Author Comment

Hi Billprew
But where  'echo' should fit in the  command because I tried few ways and it is reporting  error
Warning, unknown configuration item (BAGSALE)
Warning, unknown configuration item (echo)

F:\Program Files\Veritas\NetBackup\bin\Admincmd>bpgetconfig -M BAGSALE exclude >> echo BAGSALE E:/Exclude.txt
Warning, unknown configuration item (BAGSALE)
Warning, unknown configuration item (echo)

0

LVL 51

Accepted Solution

I think you will be doing the echo first as a seperate command.  This will write your line of text to divide the next section.  So something like this:

echo BAGSALE >>E:/Exclude.txt
bpgetconfig -M BAGSALE exclude >>E:/Exclude.txt

~bp
0

LVL 43

Expert Comment

btw i know you have your answer and bill knows this anyway but in case you dont know you can also redirect a whole batch of command in one go by enclosing them in (), e.g.

@echo off
(
echo %computername% at %date% %time%
yourprog.exe
someotherprog.exe
echo Finished %date %time%
echo.
) >logfile.txt

etc.

steve
0

Featured Post

This article will show, step by step, how to integrate R code into a R Sweave document
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…