Anthony Key
asked on
Need to use the find command and evaluate if string not found
Hi currently I'm using this logic in a script (See below) however when I recently got '10 Files copied' my logic came up with an "%errorlevel%" = 0 and therefore I emailed the wrong message.
I need to come up with a different error check maybe some thing that states that if 'Files copied' not found then "%errorlevel%" = 0 or 1. How would I do this?
Thanks,
7Souls
find /i "0 File(s) copied"
"\\dbstor\oraclebkup$\devo rasisgtid\ rman\logs\ Xcopy_rman _backup_%d ate:~4,2%% date:~7,2% %date:~10, 4%.txt"
if %errorlevel% EQU 1 (D:\adminscripts\common\bl at262\full \blat -to EMail1y@domain subject "XCOPY
of RMAN Online Backup of DSISGTD was Successful" -bodyf
\\dbstor\oraclebkup$\devor asisgtid\r man\logs\X copy_rman_ backup_%da te:~4,2%%d ate:~7,2%% date:~10,4 %.txt
) else (D:\adminscripts\common\bl at262\full \blat -to EMail1y@domain -subject "XCOPY of RMAN Online
Backup of DSISGTD Failed,so please restart XCOPY before next weekly backup" -bodyf
\\dbstor\oraclebkup$\devor asisgtid\r man\logs\X copy_rman_ backup_%da te:~4,2%%d ate:~7,2%% date:~10,4 %.txt
)
I need to come up with a different error check maybe some thing that states that if 'Files copied' not found then "%errorlevel%" = 0 or 1. How would I do this?
Thanks,
7Souls
find /i "0 File(s) copied"
"\\dbstor\oraclebkup$\devo
if %errorlevel% EQU 1 (D:\adminscripts\common\bl
of RMAN Online Backup of DSISGTD was Successful" -bodyf
\\dbstor\oraclebkup$\devor
) else (D:\adminscripts\common\bl
Backup of DSISGTD Failed,so please restart XCOPY before next weekly backup" -bodyf
\\dbstor\oraclebkup$\devor
)
ASKER
Hi knightEknight,
This makes sense xcopy does do this so if xcopy finds "File(s) copied" the %errorlevel% is 0 otherwise if find command doesn't find it the %errorlevel% is 1 correct. However what happens if I get a "0 File(s) copied" would that be the same as no files copied?
Thanks,
7Souls
This makes sense xcopy does do this so if xcopy finds "File(s) copied" the %errorlevel% is 0 otherwise if find command doesn't find it the %errorlevel% is 1 correct. However what happens if I get a "0 File(s) copied" would that be the same as no files copied?
Thanks,
7Souls
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Another approach is to trap the error right in the copy itself, so something like this:
xcopy [your command stuff here] && (
D:\adminscripts\common\blat262\full\blat -to EMail1y@domain subject "XCOPY of RMAN Online Backup of DSISGTD was Successful" -bodyf \\dbstor\oraclebkup$\devorasisgtid\rman\logs\Xcopy_rman_backup_%date:~4,2%%date:~7,2%%date:~10,4%.txt
) || (
D:\adminscripts\common\blat262\full\blat -to EMail1y@domain -subject "XCOPY of RMAN Online Backup of DSISGTD Failed,so please restart XCOPY before next weekly backup" -bodyf \\dbstor\oraclebkup$\devorasisgtid\rman\logs\Xcopy_rman_backup_%date:~4,2%%date:~7,2%%date:~10,4%.txt
)
~bp
How about this?
findstr/r "^0.File(s).copied"
findstr/r "^0.File(s).copied"
sorry bp, didn't see your post
No problem.
~bp
~bp
ASKER
Hi billprew,
I am currently testing your suggestion 'findstr /i /r /c:"^ *0 File(s) copied"'. I will let you know what I get.
Thanks,
7Souls
I am currently testing your suggestion 'findstr /i /r /c:"^ *0 File(s) copied"'. I will let you know what I get.
Thanks,
7Souls
ASKER
Hi billprew,
That did it. See below:
Xcopy started on Wed 09/14/2011 at 12:47:33
X:\rman\DSISGTD\AUTOBACKUP \2011_09_1 4\O1_MF_S_ 761801155_ 770OR4NN_. BKP
X:\rman\DSISGTD\BACKUPSET\ 2011_09_14 \O1_MF_ANN NN_TAG2011 0914T03250 2_770OPK14 _.BKP
X:\rman\DSISGTD\BACKUPSET\ 2011_09_14 \O1_MF_ANN NN_TAG2011 0914T03250 2_770OPKS1 _.BKP
X:\rman\DSISGTD\BACKUPSET\ 2011_09_14 \O1_MF_ANN NN_TAG2011 0914T03250 2_770OR05J _.BKP
X:\rman\DSISGTD\BACKUPSET\ 2011_09_14 \O1_MF_NNN DF_TAG2011 0914T03002 0_770N862D _.BKP
X:\rman\DSISGTD\BACKUPSET\ 2011_09_14 \O1_MF_NNN DF_TAG2011 0914T03002 0_770N87DO _.BKP
X:\rman\DSISGTD\BACKUPSET\ 2011_09_14 \O1_MF_NNN DF_TAG2011 0914T03002 0_770NRNNC _.BKP
X:\rman\DSISGTD\BACKUPSET\ 2011_09_14 \O1_MF_NNN DF_TAG2011 0914T03002 0_770OFG9Z _.BKP
X:\rman\DSISGTD\logs\rman_ backup_hot _full_10g_ DSISGTD_09 142011.log
X:\rman\DSISGTD\temp\rman_ backup_hot _full_10g_ DSISGTD_09 142011.rcv
10 File(s) copied
Xcopy ended on Wed 09/14/2011 at 13:09:57
Thanks,
7Souls
That did it. See below:
Xcopy started on Wed 09/14/2011 at 12:47:33
X:\rman\DSISGTD\AUTOBACKUP
X:\rman\DSISGTD\BACKUPSET\
X:\rman\DSISGTD\BACKUPSET\
X:\rman\DSISGTD\BACKUPSET\
X:\rman\DSISGTD\BACKUPSET\
X:\rman\DSISGTD\BACKUPSET\
X:\rman\DSISGTD\BACKUPSET\
X:\rman\DSISGTD\BACKUPSET\
X:\rman\DSISGTD\logs\rman_
X:\rman\DSISGTD\temp\rman_
10 File(s) copied
Xcopy ended on Wed 09/14/2011 at 13:09:57
Thanks,
7Souls
Great, glad that worked out well. Thanks.
~bp
~bp
ASKER
No bp,
Thank you..
7Souls
Thank you..
7Souls
find "File(s) copied" "Xcopy_rman_backup_%date:~
if %errorlevel% EQU 0 ( echo Files Copied ) else (echo Files NOT copied )