@echo off
:: Required Components:
:: dsjob.exe (Windows Version)
:: -----------------------------------------------------------------
:: Command Line Parameters:
:: 1. Host
:: 2. User
:: 3. Password
:: 4. Project
:: -----------------------------------------------------------------
:: Ensure that everything that are set here are not permanent.
:: -----------------------------------------------------------------
SETLOCAL
:: -----------------------------------------------------------------
:: Test for command line parameters.
:: -----------------------------------------------------------------
IF "%1"=="" GOTO Syntax
IF "%2"=="" GOTO Syntax
IF "%3"=="" GOTO Syntax
IF "%4"=="" GOTO Syntax
:: -----------------------------------------------------------------
:: Set paramters.
:: -----------------------------------------------------------------
SET Host=%1
SET User=%2
SET Password=%3
SET Project=%4
:: -----------------------------------------------------------------
:: Hard-coded values. Dependent on each computer.
:: -----------------------------------------------------------------
SET Designer=C:\Progra~1\Ascential\DataStage\dsdesign.exe
SET DsJob=C:\Progra~1\Ascential\DataStage\dsjob.exe
SET JobList=DsJobReportList.txt
SET ProjectList=ProjectList.txt
SET DSLog=DsJobReportLog
SET BackupDir=c:\DataStage\KimD\Jobs\%Project%
:: -----------------------------------------------------------------
:: Get the current Date
:: -----------------------------------------------------------------
FOR /f "tokens=2-4 delims=/ " %%a in ('DATE/T') do SET DsxDate=%%c%%a%%b
:: -----------------------------------------------------------------
:: Get the current Time
:: -----------------------------------------------------------------
FOR /f "tokens=1* delims=:" %%a in ('ECHO.^|TIME^|FINDSTR "[0-9]"') do (SET DsxTime=%%b)
:: -----------------------------------------------------------------
:: Set delimeters so that current time can be broken down into components
:: then execute FOR loop to parse the DsxTime variable into Hr/Min/Sec/Hun.
:: -----------------------------------------------------------------
SET delim1=%DsxTime:~3,1%
SET delim2=%DsxTime:~9,1%
FOR /f "tokens=1-4 delims=%delim1%%delim2% " %%a in ('echo %DsxTime%') do (
set DsxHr=%%a
set DsxMin=%%b
set DsxSec=%%c
set DsxHun=%%d
)
:: -----------------------------------------------------------------
:: If provided directory is missing an ending \, append it.
:: Validate %BackupDir%'s existance.
:: -----------------------------------------------------------------
if exist %BackupDir%\ set BackupDir=%BackupDir%\
if NOT exist %BackupDir% GOTO BadMain
:: -----------------------------------------------------------------
:: Set the log file name to improve readability of code.
SET LogFileName=%BackupDir%%DSLog%-%DsxDate%-%DsxHr%_%DsxMin%_%DsxSec%.log
:: -----------------------------------------------------------------
:: Announce to log of this program's run.
:: -----------------------------------------------------------------
ECHO. > %LogFileName%
ECHO DsJobReport ran on %DsxDate% %DsxHr%:%DsxMin%:%DsxSec% with the following parameters >> %LogFileName%
ECHO Host=%Host% >> %LogFileName%
ECHO User=%User% >> %LogFileName%
ECHO BackupDir=%BackupDir%%DsxDate%\ >> %LogFileName%
ECHO Designer=%Designer% >> %LogFileName%
ECHO DsJob=%DsJob% >> %LogFileName%
ECHO ProjectList=%ProjectList% >> %LogFileName%
ECHO JobList=%JobList% >> %LogFileName%
ECHO DSLog=%DSLog% >> %LogFileName%
ECHO. >> %LogFileName%
:: -----------------------------------------------------------------
:: Pull project information (and validate parameters).
:: -----------------------------------------------------------------
%DsJob% -server %Host% -user %User% -password %Password% -lprojects > %ProjectList%
IF NOT %ERRORLEVEL%==0 GOTO BadParam
:: -----------------------------------------------------------------
:: Pull job list
:: -----------------------------------------------------------------
%DsJob% -server %Host% -user %User% -password %Password% -ljobs %Project% > %JobList%
IF NOT %ERRORLEVEL%==0 GOTO BadParam
:: -----------------------------------------------------------------
:: Report valid projects to log.
:: -----------------------------------------------------------------
ECHO Jobs found on %Host%: >> %LogFileName%
type %JobList% >> %LogFileName%
:: -----------------------------------------------------------------
:: Create subdirectory within Backup Directory
:: Validate ability to create %BackupDir%%DsxDate%\.
:: -----------------------------------------------------------------
if exist %BackupDir%%DsxDate%\ GOTO DirCont
ECHO *** Creating: %BackupDir%%DsxDate%\
mkdir %BackupDir%%DsxDate%\
IF NOT %ERRORLEVEL%==0 GOTO BadDir
ECHO. >> %LogFileName%
ECHO *** Created: %BackupDir%%DsxDate%\ >> %LogFileName%
ECHO. >> %LogFileName%
:: -----------------------------------------------------------------
:DirCont
ECHO.
ECHO Saving Job Report on %Host% ...
ECHO.
:: -----------------------------------------------------------------
:: Begin Backup Loop
::
:: NOTE: %ERRORLEVEL% does not work for some reason.
:: -----------------------------------------------------------------
for /F "tokens=1" %%i in (%JobList%) do (
ECHO Saving Job Report on Job %%i
ECHO %Designer% /H=%Host% /U=%User% /P=%Password% %Project% %%i /R /RP=%BackupDir%%DsxDate% /RX >> %LogFileName%
%Designer% /H=%Host% /U=%User% /P=%Password% %Project% %%i /R /RP=%BackupDir%%DsxDate% /RX >> %LogFileName%
IF NOT %ERRORLEVEL%==0 GOTO ProjFail
ECHO. >> %LogFileName%
ECHO *** Completed Job Report for Job: %%i on Host: %Host% Project: %Project% >> %LogFileName%
ECHO to File: %BackupDir%%DsxDate%\%%i.html >> %LogFileName%
ECHO. >> %LogFileName%
)
:: -----------------------------------------------------------------
:: ECHO *** Export completed successfully for projects:
:: type %TempFile%
:: -----------------------------------------------------------------
GOTO EXITPT
:: -----------------------------------------------------------------
:: a job failed to be exported.
:: -----------------------------------------------------------------
:ProjFail
ECHO.
ECHO *** ERROR: Failed to Export Job: %%i on Host: %Host% on Project: %Project%
ECHO.
ECHO Please ensure that nobody else is accessing this server while you
ECHO are running this backup script.
ECHO.
ECHO. >> %LogFileName%
ECHO *** ERROR: Failed to Export Job: %%i on Host: %Host% on Project: %Project% >> %LogFileName%
ECHO. >> %LogFileName%
GOTO EXITPT
:: -----------------------------------------------------------------
:: Report that paramters are not valid on screen and log file.
:: Note: Password are not reported for better security.
:: -----------------------------------------------------------------
:BadParam
echo.
echo Invalid parameters - Unable to access Server.
echo.
echo. >> %LogFileName%
echo Invalid parameters - Unable to access Server. >> %LogFileName%
echo. >> %LogFileName%
GOTO Syntax
:: -----------------------------------------------------------------
:: Report that directory is non-existant.
:: -----------------------------------------------------------------
:BadMain
echo.
echo Bad/Non-existing directory: %BackupDir%
echo.
echo Please ensure that you have permission to access/create directories
echo and files. Also ensure that directory listed exists.
echo.
echo. >> %LogFileName%
echo Bad/Non-existing directory: %BackupDir% >> %LogFileName%
echo. >> %LogFileName%
GOTO EXITPT
:: -----------------------------------------------------------------
:: Report that program does not have privs to create directory.
:: -----------------------------------------------------------------
:BadDir
echo.
echo Unable to create subdirectory: %BackupDir%%DsxDate%\
echo.
echo Please ensure that you have permission to access/create directories
echo and files.
echo.
echo. >> %LogFileName%
echo Unable to create subdirectory: %BackupDir%%DsxDate%\ >> %LogFileName%
echo. >> %LogFileName%
GOTO EXITPT
:: -----------------------------------------------------------------
:: Report proper syntax usage.
:: -----------------------------------------------------------------
GOTO ENDPOINT
:: -----------------------------------------------------------------
:EXITPT
ECHO. >> %LogFileName%
:: -----------------------------------------------------------------
:ENDPOINT
ENDLOCAL
Translate to your Language
Labels
- BI
- Big Data
- BO
- BO Universe Context
- BusinessObjects Context
- BusinessObjects Universe Context
- Cognos
- Command Line DataStage Job Export
- DataStage
- DataStage Command Line Compile
- DataStage Job Compile in command line
- DataStage SCD
- DataStage Server JobCompile Script
- DB
- DW
- DW-SCD
- Optimizing BO Universe and Reports
- Optimizing Business Objects Universe and Reports
- Other
- Q&A
- SAP BO
- SCD
Disclaimer Statement
Total Pageviews
Category
- BI
- Big Data
- BO
- BO Universe Context
- BusinessObjects Context
- BusinessObjects Universe Context
- Cognos
- Command Line DataStage Job Export
- DataStage
- DataStage Command Line Compile
- DataStage Job Compile in command line
- DataStage SCD
- DataStage Server JobCompile Script
- DB
- DW
- DW-SCD
- Optimizing BO Universe and Reports
- Optimizing Business Objects Universe and Reports
- Other
- Q&A
- SAP BO
- SCD
Track
Follow us on FaceBook
About
Powered by Blogger.
Category
- BI
- Big Data
- BO
- BO Universe Context
- BusinessObjects Context
- BusinessObjects Universe Context
- Cognos
- Command Line DataStage Job Export
- DataStage
- DataStage Command Line Compile
- DataStage Job Compile in command line
- DataStage SCD
- DataStage Server JobCompile Script
- DB
- DW
- DW-SCD
- Optimizing BO Universe and Reports
- Optimizing Business Objects Universe and Reports
- Other
- Q&A
- SAP BO
- SCD
Contributors
Blog Archive
-
▼
2013
-
▼
January
- Datastage Job Report Script
- Ton of Data Warehousing and Datastage Interview Qu...
- Informatica Interview Questions
- Data Warehousing Interview Questions
- Datastage Interview Questions and Answers
- DATASTAGE Questions and Answers
- Types of Measures in Fact Tables
- Learn Datastage 8.5 step by step
- Web Intelligence Documents-Filters and Prompts
- Drill in Web Intelligence Charts and Tables
-
▼
January
Popular Posts
-
Netezza dosen't have any isnumeric check function, so in order to find out whether the column has non-numeric, use the following logic n...
-
If you have table like below GROUP_NAME GROUP_ID PASS_FAIL COUNT GROUP1 5 FAIL 382 GROUP...
-
@echo off :: ----------------------------------------------------------------- :: DataStageExport.bat :: -----------------------------------...
-
Netezza has 3 internal planner Fact Relationship Planner (factrel_planner) Snowflake Planner Star Planner In the course of a query pla...
-
What is Big Data? Big data is data that exceeds the processing capacity of traditional database systems. The data is too big, moves too fast...
-
Source :-dwh-ejtl.blogspot.com Q1) Tell me what exactly, what was your role? A1) I worked as ETL Developer. I was also involved in requireme...
-
One of the regular viewer of this blog requested me to explain the important's of the ETL mapping document. What is ETL Mapping Document...
-
I am sure most of you heard about market buzz words nosql,newsql... and it often make our DW developers to get confused on this new terms.Mo...
-
In data warehousing, a conformed dimension is a dimension that has the same meaning to every fact table in the structure. Conformed dim...
-
This note assumes some familiarity with the DataStage transformation engine. DataStage is normally used to process multiple input files and/...
Tuesday, January 15, 2013
Datastage Job Report Script
by Unknown | 
in DataStage
at 4:37 AM
-
Netezza ISNUMERIC Data Check Logic
-
How to do PIVOT in netezza SQL
-
Datastage DSX Files Export Script
-
Netezza Optimizer Parameters
-
Big Data and Hadoop Questions and Answers
-
Informatica Job Interview Question & Answers
-
What is ETL Mapping Document ?A Real Time Example
-
NOSQL 101
-
Conformed Dimensions with example
-
Data Generation Using DataStage
0 comments: