batch file - Why is IBM Tivoli Netcool Omnibus's Summary is not fully printed? -
i need print omnibus "summary" string. have trigger executes procedure:
begin each row critical in alerts.status critical.alertkey = 'disk_usage_crit' begin execute send_email( critical.node, critical.severity, critical.alertkey, 'netcoolemail', critical.summary, 'winitmsvr631'); end; end
that trigger passes values of critical node, severity, alertkey, 'netcoolemail', summary , host name parameters procedure named send_email
.
this procedure body:
(node char(1), severity int, situation char(1), email char(1), summary char(1), hostname (1)).
this procedure passes values of parameters variables in batch file.
set node=%1 set situation=%3 set summary=%5 echo %node% >> c:\ibm\logtest.txt echo %situation% >> c:\ibm\logtest.txt echo %summary% >> c:\ibm\logtest.txt
when echo variables , redirect them text file, summary
string truncated while others being printed expected.
this how summary variable looks if it's printed:
disk_usage_crit[(%_used>=1 , wtlogcldsk.instcname , disk_name="c:" ) on primary:winsvr2k8:nt on c: (%_used=41 disk_name=c: )]
and yet, printed this:
disk_usage_crit[(%_used
the rest not being printed.
why summary string not output completely?
each percent sign %
in string should interpreted literal character within command process , not begin/end of environment variable reference must doubled.
but if summary string passed batch file as:
"disk_usage_crit[(%_used>=1 , wtlogcldsk.instcname , disk_name="c:" ) on primary:winsvr2k8:nt on c: (%_used=41 disk_name=c: )]"
with double quote @ beginning , double quote @ end last parameter, not necessary replace each %
%%
if using in batch file additionally delayed environment variable expansion.
the reason truncation >
being interpreted command redirection operator if not found within double quoted string , not using delayed environment variable expansion.
therefore required here use delayed expansion on echoing values of environment variables containing characters special meaning windows command interpreter.
@echo off setlocal enableextensions enabledelayedexpansion set "node=%~1" set "situation=%~3" set "summary=%~5" echo !node!>>c:\ibm\logtest.txt echo !situation!>>c:\ibm\logtest.txt echo !summary!>>c:\ibm\logtest.txt endlocal
see answer on why no string output 'echo %var%' after using 'set var = text' on command line? why using set "variable=value"
. first double quote left variable name , not right of equal sign. makes big difference referenced answer explains in detail.
the space character left of each redirection operator >>
removed avoid writing trailing space on each line text file. space character right of each redirection operator >>
not matter, here nevertheless removed, too.
for more information delayed environment variable expansion open command prompt window, run set /?
, read output pages command carefully.
Comments
Post a Comment