Page 1 of 2

ExecCommand

Posted: Wed Nov 21, 2007 8:30 am
by Raftsman
We have multiple environments. I would like to use the Exec Command stage to execute a BAT file. The problem is, I would like to change the directory structure to point to the Environment where the BAT file resides. I tried the following

ExecCommand: D:\DataStage\

Parameter: #ENV#\Test.bat

Because D:\Datastage\ isn't a command, it fails. Is there a prefix I can add to make it a command.

Thanks

Posted: Wed Nov 21, 2007 8:49 am
by chulett
In DOS? Hmmm....

Maybe using 'start'? Or perhaps a generic batch file in a fixed location that does a 'call' to the correct batch file?

Really getting into the WABAC Machine for that stuff. :wink:

Posted: Wed Nov 21, 2007 8:58 am
by Raftsman
Yes, but what are my other alternatives on a Windows box. Can I create a UNIX script and call it. Would this work with the MKS Toolkit.

Posted: Wed Nov 21, 2007 9:05 am
by chulett
Sure, if you have the MKS Toolkit then you have alot of other options, including scripting something.

Posted: Wed Nov 21, 2007 10:26 am
by Minhajuddin
Hi Craig,

If I am not wrong. MKS ToolKit is installed by default on all windows installations of Datastage.

Posted: Wed Nov 21, 2007 10:30 am
by gateleys
Minhajuddin wrote:Hi Craig,

If I am not wrong. MKS ToolKit is installed by default on all windows installations of Datastage.
You are wrong. I have worked in various versions, the latest being 7.5.1A (DS Server ed. on Windows) and MKS ToolKit was not included. I think it has been made available in 7.5.2 Windows Ed.

Posted: Wed Nov 21, 2007 10:35 am
by Minhajuddin
My bad :oops:

I should have said Datastage "Enterprise Edition"

Posted: Wed Nov 21, 2007 10:39 am
by gateleys
Even if you don't have MKS ToolKit, you could install Cygwin to provide you with the Unix layer. It comes free.

Posted: Wed Nov 21, 2007 1:16 pm
by chulett
From what I understand - yes, it does come 'free' with EE. Someone may have chosen not to install it. Or, as noted, there are other alternatives.

Posted: Wed Nov 21, 2007 2:12 pm
by ray.wurlod
D:DataStage can never be a command, I don't care how many prefixes you add to it. It's a Folder, pure and simple.

What precisely are you trying to achieve?

The best practice with scripts (or BAT files) is to use full pathnames. If you can't do that, use CD commands to get you where you need to be - and, if necessary, capture the current working directory's pathname before you do, so you can CD back again.

Posted: Wed Nov 21, 2007 2:26 pm
by jdmiceli
Also, if you have parameterized your paths for job control, then you can refer to the parameter using the standard #parametername# notation.

Posted: Wed Nov 21, 2007 3:00 pm
by Raftsman
Ray,

But if we don't want a common directory to store script, is there a way to distinguish the directory path where the script resides.

I have been trying to use the CMD command and concatinate the parameter line. It's not working. Now I am trying to use the sh -c command. Still having problems with this.

Hopefully, I figure it out.

Posted: Wed Nov 21, 2007 3:14 pm
by gateleys
Why not use a Before/After job/stage subroutine 'ExecDOS' to call the bat with the required parameter?
OR
Use a CommandStage (not ExecuteCommand in job sequence) within a job.

Posted: Wed Nov 21, 2007 4:51 pm
by ray.wurlod
OK, then start is a good suggestion on Windows (like source would be on UNIX).

The start command has plenty of useful options, too. Get to a CMD shell and type HELP START to get more information.

You can then put the entire command line that you actually want to execute into the Parameters field of the Execute Command activity.

Posted: Wed Nov 21, 2007 6:05 pm
by chulett
Forgot to mention that part - just 'start' as the command and everything else in the Parameter box. Thanks.

The biggest thing to realize with that stage is you can't put "half" of the command in one box and the other half in the second box as, when they are combined to be executed, a space is left between the two. That was your original problem, Raftsman.