Page 1 of 2

Execute Command stage

Posted: Mon Aug 18, 2008 11:16 am
by Javieregh
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

Posted: Mon Aug 18, 2008 11:38 am
by chulett
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? :?

Posted: Mon Aug 18, 2008 11:49 am
by Javieregh
chulett 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? :? ...
I change it to CMD, stays in DataStage directory and does not change the directory LAN

Output from command ====>
Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.

C:\DSProjects\DEVL_DM>

Posted: Mon Aug 18, 2008 12:36 pm
by chulett
No idea what to try next. Worst case, write a routine to use DSExecute( ) and run with a Routine Activity stage instead.

Posted: Mon Aug 18, 2008 1:57 pm
by lstsaur
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.

Posted: Mon Aug 18, 2008 2:18 pm
by jguerrero
Hi,

Do you try to use:

Command:#seq_path#\#APORIProcessDeleteFile#
Parameter: (what you need inside the script)

Posted: Mon Aug 18, 2008 2:20 pm
by Javieregh
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.
The dslog is:
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"

Posted: Mon Aug 18, 2008 2:23 pm
by Javieregh
jguerrero wrote:Hi,

Do you try to use:

Command:#seq_path#\#APORIProcessDeleteFile#
Parameter: (what you need inside the script)
Command: cmd
Parameters: "#seq_path#\#APORIProcessDeleteFile#"

#seq_path# = \\filedev\ETLDataFiles\Devl\DM\XXX\Test1\
#APORIProcessDeleteFile# = deletefile.bat

Posted: Mon Aug 18, 2008 2:24 pm
by chulett
jguerrero wrote:Do you try to use:

Command:#seq_path#\#APORIProcessDeleteFile#
Parameter: (what you need inside the script)
You can't because no parameter substitution is done in the Command box.

Posted: Mon Aug 18, 2008 3:14 pm
by lstsaur
Try the following:

Command: START
Parameters: #seq_path# #APORIProcessDeleteFile#

#seq_path# = \\filedev\ETLDataFiles\Devl\DM\XXX\Test1\
#APORIProcessDeleteFile# = deletefile.bat

Posted: Mon Aug 18, 2008 3:21 pm
by chulett
Wow. My DOS memories are cautiously raising their heads from the depths I banished them to years ago. Start, pushd, popd... expanded memory, extended memory... ah, those were the days. :wink:

Posted: Mon Aug 18, 2008 3:23 pm
by Javieregh
lstsaur wrote:Try the following:

Command: START
Parameters: #seq_path# #APORIProcessDeleteFile#

#seq_path# = \\filedev\ETLDataFiles\Devl\DM\XXX\Test1\
#APORIProcessDeleteFile# = deletefile.bat
did nothing, I think the problem is not changing the directory by default DataStage

Posted: Mon Aug 18, 2008 3:37 pm
by chulett
You have no idea and the pushd/popd mask things. Why not comment out the "@echo off" for now and see what it logs?

Posted: Tue Aug 19, 2008 8:30 am
by Javieregh
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? ...
I put the @echo off in comment and it didn't work, I am obtaining this when I run log:

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

Posted: Tue Aug 19, 2008 9:22 am
by chulett
What do you mean it "didn't work"? :? Removing it should allow everything written to 'the screen' to be captured in the log. It wasn't meant to fix anything but rather give you an idea what needed to be fixed.