@echo off setlocal enabledelayedexpansion set z_path=%~dp0 set z_name=%~n0 set z_file_log=!z_path!!z_name!.log set z_file_mon=!z_path!netbackup-tape-drive-status.mon set z_master=mymaster if exist "!z_file_log!" del "!z_file_log!" REM ### We Don't delete the file, leave it there, and the display script will work out how old the contents are... REM if exist "!z_file_mon!" del "!z_file_mon!" call :log "" call :log "################################################" call :log "Script started..." call :log "" call :log "Pinging master server `!z_master!`..." ping !z_master! > nul set z_sts=!errorlevel! if "!z_sts!"=="0" ( call :log "Done..." ) else ( call :log "Master server does not ping, status `!z_sts!`..." goto :end ) call :log "" call :log "Checking whether NetBackup is up on master server..." vmdareq -hostinfo > nul set z_sts=!errorlevel! if "!z_sts!"=="0" ( call :log "Done..." ) else ( call :log "NetBackup appears to be down on master server `!z_master!`, status `!z_sts!`..." goto :end ) call :log "" call :log "Requesting vmoprcmd -devmon..." vmoprcmd -M !z_master! -devmon > "!z_file_mon!" set z_sts=!errorlevel! if "!z_sts!"=="0" ( call :log "Done..." ) else ( call :log "Failed, status `!z_sts!`..." ) :end call :log "" call :log "Script exiting..." exit /b :log echo !date! !time:~0,8! %~1 echo !date! !time:~0,8! %~1 >> "!z_file_log!" goto :eof