how to have only the results of the commands echoed to the file, and not the
commands themselves ... ?
The "Redir Rapids" Series of .Mount/\Commands provide fine tuned control
over where the output of any program, command or script is directed. A
color-keyed version of the example below is at
(
http://TheSystemGuard.com/MtCmds/RedirRapids/Show.htm).
*******
C:\GuardPost>ntlib /quiet :File_Number_Lines redir_demo.cmd
C:\GuardPost>set _fnl
_FNL=Redir_Demo.cmd.numbered.txt
C:\GuardPost>type %_fnl%
01. @ECHO OFF
02.
03. :* Create a zero length file to use for the demo
04. %.ZeroFile% FileName.Ext
05.
06. IF EXIST FileName.Ext %.Silent% (
07. (ECHO: {Silent} Normal Message 1)
08. (%.ErrEcho% {Silent} Error Message 1)
09. )
10.
11. IF EXIST FileName.Ext %.Quiet% (
12. (ECHO: {Quiet} Normal Message 2)
13. (%.ErrEcho% {Quiet} Error Message 2)
14. )
15.
16. IF EXIST FileName.Ext %.Kity% (
17. (ECHO: {Kity} Normal Message 3)
18. (%.ErrEcho% {Kity} Error Message 3)
19. )
20.
21. IF EXIST FileName.Ext %.Show% (
22. (ECHO: {Show} Normal Message 4)
23. (%.ErrEcho% {Show} Error Message 4)
24. )
25.
26. IF EXIST FileName.Ext %.ShowErr% (
27. (ECHO: {ShowErr} Normal Message 5)
28. (%.ErrEcho% {ShowErr} Error Message 5)
29. )
30.
31. IF EXIST FileName.Ext %.ShowAll% (
32. (ECHO: {ShowAll} Normal Message 6)
33. (%.ErrEcho% {ShowAll} Error Message 6)
34. )
35.
36. :* Delete the demo file
37. DEL FileName.Ext
*******
[Normal Mode - No Redirection]
C:\GuardPost>Redir_Demo
{Quiet} Error Message 2
{Kity} Normal Message 3
{Show} Normal Message 4
{Show} Error Message 4
{ShowErr} Normal Message 5
{ShowErr} Error Message 5
{ShowAll} Normal Message 6
{ShowAll} Error Message 6
[Quiet Mode - Direct normal output to NUL]
C:\GuardPost>Redir_Demo >NUL
{Quiet} Error Message 2
{Show} Normal Message 4
{Show} Error Message 4
{ShowErr} Error Message 5
{ShowAll} Normal Message 6
{ShowAll} Error Message 6
[Silent Mode - Direct normal output and errors to NUL]
C:\GuardPost>Redir_Demo >NUL 2>&1
{Show} Normal Message 4
{ShowErr} Error Message 5
{ShowAll} Normal Message 6
{ShowAll} Error Message 6
*******
ZeroFile - Creates a zero-byte file or
"zeroes out" an existing file
KITY - Keep It To Yourself
(i.e., suppress errors only)
*******
File_Number_Lines can also be invoked using it's short name:
ntlib :FNL FileToNumber
The name of the output file will be returned in the variable %_FNL%.
See an example at
(
http://TheSystemGuard.com/NTCmdLib/Procedures/FNL.htm)
*******
Notes:
1. .Mount/\Commands are constructed using ONLY builtin
commands common to all four platforms (NT/2K/XP/K3).
2. .M/\C's are NOT case sensitive. Mixed case is used
for visual clarity only.
3. ntlib.cmd provides over 100 resources to assist with
writing and documenting cross-platform scripts,
including 57 .Mount/\Commands. You can obtain it
(for FREE) at (
http://ntlib.com).
*******
TheGuardBook contains a "Mounted Help" page for each internal cmd.exe
command. This is a single color-keyed page, highlighting the differences
among the NT/2K/XP/K3 versions. The complete help text for each OS is also
available for comparison (
http://TheSystemGuard.com/TheGuardBook/CCS-Int).
*******
-tsg
____________________________________________________________
TheSystemGuard.com | BoomingOrFuming.com | MountCommands.com
Free and "Almost Free" Knowledge for Windows System Admins!