Video Screencast Help
Symantec Appoints Michael A. Brown CEO. Learn more.

need help in modifying the subject line

Created: 06 Dec 2012 • Updated: 12 Dec 2012 | 6 comments
Anurag Sharma's picture
This issue has been solved. See solution.

**** Moved to new discussion from https://www-secure.symantec.com/connect/forums/how-exclude-157150-error-blat  ****

Yasuhisa Ishikawa,

No Doubts excellent progamming work by you.

I'm one of the colleguage with Phani Kumar.

This script is sending and email for backup failures for all status codes apart from the excluded ones.

The subject of the email is " Backup on CLIENTNAME - STATUS CODE

for example

 

==============================================================================

 

From: NetBackup@xyz.com
Sent: Friday, December 07, 2012 9:42 AM
To: xx.com
Subject: Backup on PNORS474 - 50

 

Backup on client PNORS474 for user root by server MPS6741 failed.

 

Status = client process aborted.

 

Policy = Daily_Incr_2200_SAT_FULL

Schedule = DIFF

 

File list

---------

ALL_LOCAL_DRIVES

===============================================================================

 

We need you help in modifying the subject line from Backup on CLIENTNAME to Backup Failed on CLIENTNAME something like

from Backup on PNORS474 - 50 to Backup failed on PNORS474 - 50

 

If you go further down the script this the portion which determines the subject

 

==========================================================

@REM -      %1 is the recipient's address                                      -
@REM -      %2 is the subject line                                             -
@REM -      %3 is the message file name                                        -
@REM -      %4 is the attached file name      @REM -      %1 is the recipient's address                                      -
@REM -      %2 is the subject line                                             -
@REM -      %3 is the message file name                                        -
@REM -      %4 is the attached file name      

 

IF "%~4"=="" (
blat %3 -s %2 -t %1 -i NetBackup -server smtp.moc.com -q
)ELSE (
blat %3 -s %2 -t %1 -i NetBackup -server smtp.moc.com -q -attach %4
)
 

===============================================================

-s is the varible with value %2 passed to the blat function/binary we some how need to modify that to reflect backup failed on instead of backup on.

 

Discussion Filed Under:

Comments 6 CommentsJump to latest comment

Yasuhisa Ishikawa's picture

Probably this will work.

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /F "tokens=5" %%i IN ("%2") DO SET STATUS=%%i
SET STATUS=!STATUS:~0,-1!
IF "%STATUS%"=="0" GOTO :EOF
IF "%STATUS%"=="90" GOTO :EOF
IF "%STATUS%"=="150" GOTO :EOF
IF "%STATUS%"=="157" GOTO :EOF
IF "%STATUS%"=="190" GOTO :EOF

FOR /F "tokens=1,2,3,4,5" %%i IN ("%2") DO SET SUBJECT=%%i failed %%j %%k %%l %%m


IF "%~4"=="" (
blat %3 -s %SUBJECT% -t %1 -i NetBackup -server smtp.moc.com -q
)ELSE (
blat %3 -s %SUBJECT% -t %1 -i NetBackup -server smtp.moc.com -q -attach %4
)

blat %TEMP%\nbmail.tmp -s %SUBJECT% -t %1 -server smtp.moc.com >> D:\BUR_Scripts\Reports\DR File Email\nbmaillog.txt
) ELSE (
blat %TEMP%\nbmail.tmp -s %SUBJECT% -t %1 -server smtp.moc.com >> D:\BUR_Scripts\Reports\DR File Email\nbmaillog.txt -attach %4
) 
AttachmentSize
nbmail.txt 6.14 KB

Authorized Symantec Consultant(ASC) Data Protection in Tokyo, Japan

SOLUTION
Yasuhisa Ishikawa's picture

Anurag,

Does this work on your environment? Please give me your feedback.

Authorized Symantec Consultant(ASC) Data Protection in Tokyo, Japan

Anurag Sharma's picture

Yes Yashuhisa !!!

 

It worked.

 

Could you please tell me which programming language this script is written ?

 

 

Yasuhisa Ishikawa's picture

Windows batch scripting using builtin commands - not a programming language.

Authorized Symantec Consultant(ASC) Data Protection in Tokyo, Japan

Anurag Sharma's picture

Yasuhisa,

Do you know any good resource which can teach me about this batch scripting

Yasuhisa Ishikawa's picture

Only thing I know as reference is online help of builtin commands in Commad Prompt.
I used to see online help by hitting below commands or so in Command Prompt, then write batch, and test again and again.

help set
help for
help if
help setlocal

Authorized Symantec Consultant(ASC) Data Protection in Tokyo, Japan