BAT批处理脚本导出导入编译DataStage作业

本文遵循BY-SA版权协议,转载请附上原文出处链接。


本文作者: 黑伴白

本文链接: http://heibanbai.com.cn/posts/abc0cc0f/

BAT批处理脚本导出导入编译DataStage作业

  • 将下述源码放入文本文件中, 并将文件后缀名改为.bat
  • 将整理好的bat脚本文件放到datastage客户端目录下:~\InformationServer\Clients\Classic
  • 脚本参数
    • 参数1: export(导出) / import(导入)
    • 参数2: 工程名
    • 参数3: 作业清单文件(一个作业 名称一行)
    • 参数4: 导出/导入作业的dsx文件所在目录
    • 导出: export RUNMDS D:\job.list D:\path
    • 导入: import RUNMDS D:\job.list D:\path (导入后同步进行编译)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
@Title 通过DataStage客户端工具自动导入导出DataStage作业-dsx文件

@echo off & setlocal enabledelayedexpansion

rem 背景色: 0-黑色 1-蓝色 2-绿色 3-湖蓝色 4-红色 5-紫色 6-黄色 7-白色 8-灰色 9-浅蓝色
rem 字体色: a-浅绿色 b-浅水绿 c-浅红色 d-浅紫色 e-浅黄色 f-亮白色
color 0f

::窗口大小
@mode con lines=50 cols=150

echo.
echo Ahthor : heibanbai.com.cn
echo Date : 2024-08-08
echo Desc : export datastage jobs to jobname.dsx(one job one job.dsx), import file.dsx into datastage project
echo.

::Information of environment
set domain=199.188.166.111:9446
set hostname=heibanbai
set user=wasadmin
set password=wasadmin

::检查当前程序所在目录是否正确 应放在客户端工具所在目录下
dir dscmdimport.exe > nul 2<&1
if "%errorlevel%"=="1" (echo Path is error, please put this program into the path of ~\InformationServer\Clients\Classic...
goto exit)
dir dsexport.exe > nul 2<&1
if "%errorlevel%"=="1" (echo Path is error, please put this program into the path of ~\InformationServer\Clients\Classic...
goto exit)

echo --------------------------------------------
echo Import Job need 4 parameters, for example:
echo import RUNMDS D:\job.list D:\path
echo --------------------------------------------
echo Export Job need 4 parameters, for example:
echo export RUNMDS D:\job.list D:\path
echo --------------------------------------------
echo.

:pinput
echo Please intput the rigth parameters (q=exit) :
set /p params=
if "%params%"=="q" goto exit
goto checkpara
echo.

:checkpara
set num=0
for %%i in (%params%) do (
set /a num+=1
set param!num!=%%~i
)
if not %num%==4 goto pinput

set type=%param1%
set project=%param2%
set joblist=%param3%
set dsxpath=%param4%

set ymd=%date:~0,4%%date:~5,2%%date:~8,2%
set ymd_t=%ymd%_%time:~0,2%%time:~3,2%%time:~6,2%
set ymd_t=%ymd_t: =0%

if "%type%"=="import" goto doimport
if "%type%"=="export" goto doexport
goto pinput

:doimport
if not exist "%dsxpath%" (
echo dsxpath %dsxpath% not exist...
goto pinput
)
echo ######################################################################################
echo ######################################################################################>%dsxpath%\%ymd_t%.log
echo Begin import the dsx file in %dsxpath% into project %project%, please wait......
echo Begin import the dsx file in %dsxpath% into project %project%, please wait......>>%dsxpath%\%ymd_t%.log
echo ######################################################################################
echo ######################################################################################>>%dsxpath%\%ymd_t%.log
set num=0
for /f "delims=" %%i in (%joblist%) do (
set /a num+=1
if exist "%dsxpath%\%%i.dsx" (
dscmdimport /D=%domain% /H=%hostname% /U=%user% /P=%password% /NUA %project% %dsxpath%\%%i.dsx /V>%dsxpath%\%ymd_t%_import.tmp
type %dsxpath%\%ymd_t%_import.tmp
type %dsxpath%\%ymd_t%_import.tmp>>%dsxpath%\%ymd_t%.log
echo DSX !num! : %dsxpath%\%%i.dsx is imported ok...
echo DSX !num! : %dsxpath%\%%i.dsx is imported ok...>>%dsxpath%\%ymd_t%.log

dscc /d %domain% /h %hostname% /u %user% /p %password% %project% /J %%i>%dsxpath%\%ymd_t%_import.tmp
type %dsxpath%\%ymd_t%_import.tmp
type %dsxpath%\%ymd_t%_import.tmp>>%dsxpath%\%ymd_t%.log
echo JOB !num! : %%i is compiled ok...
echo JOB !num! : %%i is compiled ok...>>%dsxpath%\%ymd_t%.log
echo ************************
echo ************************>>%dsxpath%\%ymd_t%.log
) else (
echo DSX !num! : %dsxpath%\%%i.dsx not exist...
echo DSX !num! : %dsxpath%\%%i.dsx not exist...>>%dsxpath%\%ymd_t%.log
echo DSX !num! : %dsxpath%\%%i.dsx not exist...>>%dsxpath%\%ymd_t%.err
echo ************************
echo ************************>>%dsxpath%\%ymd_t%.log
)
)
echo All the job has been imported, you can check log [ %dsxpath%\%ymd_t%.log %dsxpath%\%ymd_t%.err]...
echo All the job has been imported, you can check log [ %dsxpath%\%ymd_t%.log %dsxpath%\%ymd_t%.err ]...>>%dsxpath%\%ymd_t%.log
echo.

goto pinput

:doexport
if not exist %dsxpath% md %dsxpath%
echo ######################################################################################
echo ######################################################################################>>%dsxpath%\%ymd_t%.log
echo Begin export the Jobs in %project% %joblist% to dir %dsxpath%, please wait......
echo Begin export the Jobs in %project% %joblist% to dir %dsxpath%, please wait......>>%dsxpath%\%ymd_t%.log
echo ######################################################################################
echo ######################################################################################>>%dsxpath%\%ymd_t%.log

set num=0
for /f "delims=" %%J in (%joblist%) do (
dsexport.exe /D=%domain% /H=%hostname% /U=%user% /P=%password% %project% /Job=%%J /NODEPENDENTS %dsxpath%\%%J.dsx
set /a num+=1
echo JOB !num! : %%J is ok...
echo JOB !num! : %%J is ok...>>%dsxpath%\%ymd_t%.log
)
echo All the job has been exported...
echo All the job has been exported...>>%dsxpath%\%ymd_t%.log
echo .

goto pinput

:exit
echo Press any key to exit......
pause>nul
exit

蚂蚁🐜再小也是肉🥩!


BAT批处理脚本导出导入编译DataStage作业
http://heibanbai.com.cn/posts/abc0cc0f/
作者
黑伴白
发布于
2024年8月9日
许可协议

“您的支持,我的动力!觉得不错的话,给点打赏吧 ୧(๑•̀⌄•́๑)૭”

微信二维码

微信支付

支付宝二维码

支付宝支付