Execute Command stage
Moderators: chulett, rschirm, roy
Execute Command stage
Hi
I'm using in Execute Command stage to call a DOS batch script that in turn runs .bat, my parameters is:
Command: @
Parameters: "#seq_path#\#APORIProcessDeleteFile#" ( \\filedev\ETLDataFiles\Devl\DM\XXX\Test1\deletefile.bat )
But I have trouble because it does not make the call to the script: the contents of the bat is as follows:
(Delete files with more than 6 months)
@echo off
setlocal
set cutOff=%~2
set workDir=%~1
if "%1"=="" set workDir=.
if not "%cutOff%"=="" goto START
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do (
set mm=%%a
set dd=%%b
set yyyy=%%c
)
set /a mm=1%mm% -6 - 101
if /i %mm% LSS 1 set /a mm=12&set /a yyyy-=1
if /i %mm% LSS 10 set mm=0%mm%
set cutOff=%yyyy%%mm%%dd%
:START
pushd.
cd /D "%workDir%"
for /f "delims=" %%a in ('dir /b /a-d 2^>NUL') do if /i "%%a" NEQ "%0" call :PROCESS "%%a" %%~ta
popd
goto :EOF
:PROCESS
for /f "tokens=1-3 delims=/" %%a in ('echo %2') do (
set cmm=%%a
set cdd=%%b
set cyyyy=%%c
)
if /i "%cyyyy%%cmm%%cdd%" LEQ "%cutOff%" del %1
Thanks advanced.
Javier
I'm using in Execute Command stage to call a DOS batch script that in turn runs .bat, my parameters is:
Command: @
Parameters: "#seq_path#\#APORIProcessDeleteFile#" ( \\filedev\ETLDataFiles\Devl\DM\XXX\Test1\deletefile.bat )
But I have trouble because it does not make the call to the script: the contents of the bat is as follows:
(Delete files with more than 6 months)
@echo off
setlocal
set cutOff=%~2
set workDir=%~1
if "%1"=="" set workDir=.
if not "%cutOff%"=="" goto START
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do (
set mm=%%a
set dd=%%b
set yyyy=%%c
)
set /a mm=1%mm% -6 - 101
if /i %mm% LSS 1 set /a mm=12&set /a yyyy-=1
if /i %mm% LSS 10 set mm=0%mm%
set cutOff=%yyyy%%mm%%dd%
:START
pushd.
cd /D "%workDir%"
for /f "delims=" %%a in ('dir /b /a-d 2^>NUL') do if /i "%%a" NEQ "%0" call :PROCESS "%%a" %%~ta
popd
goto :EOF
:PROCESS
for /f "tokens=1-3 delims=/" %%a in ('echo %2') do (
set cmm=%%a
set cdd=%%b
set cyyyy=%%c
)
if /i "%cyyyy%%cmm%%cdd%" LEQ "%cutOff%" del %1
Thanks advanced.
Javier
Consultant in DTS
I change it to CMD, stays in DataStage directory and does not change the directory LANchulett wrote:I don't think "@" (no echo) will work as the command. With everything parameterized it typically is a "shell" command so perhaps "cmd" would work for Windows there?...
Output from command ====>
Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.
C:\DSProjects\DEVL_DM>
Consultant in DTS
The dslog is:lstsaur wrote:It looks like both your pushd. and popd are not working. Put a test statement after the cd /D "%workDir%" to make sure your "cd" to that directory is successful. Don't just assume it's in the specified directory.
Output from command ====>
Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.
C:\DSProjects\DEVL_DM>
and should be "\filedev\XXX\XXX\ISB\Standing\ETLDataFiles\Test1"
Consultant in DTS
Command: cmdjguerrero wrote:Hi,
Do you try to use:
Command:#seq_path#\#APORIProcessDeleteFile#
Parameter: (what you need inside the script)
Parameters: "#seq_path#\#APORIProcessDeleteFile#"
#seq_path# = \\filedev\ETLDataFiles\Devl\DM\XXX\Test1\
#APORIProcessDeleteFile# = deletefile.bat
Consultant in DTS
I put the @echo off in comment and it didn't work, I am obtaining this when I run log:chulett wrote:You have no idea and the pushd/popd mask things. Why not comment out the "@echo off" for now and see what it logs? ...
The dslog is:
Output from command ====>
C:\DSProjects\DEVL_DM>
(this one is the Datastage directory)
and I'm expecting to be in this directory "\filedev\XXX\XXX\ISB\Standing\ETLDataFiles\Test1"
I'm using in Execute Command stage and my parameters are:
Command: START
Parameters: #seq_path# #APORIProcessDeleteFile#
#seq_path# = \\filedev\ETLDataFiles\Devl\DM\XXX\Test1\
#APORIProcessDeleteFile# = deletefile.bat
Do you have any script or any suggestion to change directories.
Thank you for your help
Consultant in DTS