Page 1 of 2

Execute Unix commands in datastage

Posted: Mon Sep 22, 2008 2:16 am
by Magesh_bala
Hi All,

How to execute unix commands in Datasatge.

path/ Touch File.txt
path/ rm File.txt

Is this commands will work from datastage?

Re: Execute Unix commands in datastage

Posted: Mon Sep 22, 2008 2:25 am
by sachin1
where you want to execute these commands, i mean before/afte job subroutine or in basic code.

Posted: Mon Sep 22, 2008 2:26 am
by hamzaqk
specify the command in the job properties tab (either in the before or after job ) Select Execsh in the drop down list and infront of it specify the command you want to execute

Posted: Mon Sep 22, 2008 3:28 am
by Magesh_bala
I have to use this in sequence job, I belive only shell scripts can be executed in the before/after execute job execsh, Is there any other option to execute the unix commands directly in datastage.

Posted: Mon Sep 22, 2008 3:43 am
by ray.wurlod
In job sequences you have the Execute Command activity available. Does that name suggest its possible purpose?

Posted: Mon Sep 22, 2008 4:12 am
by Magesh_bala
In Execute command we cant execute the shell script commands, We can call only the shell scripts files.

Posted: Mon Sep 22, 2008 4:41 am
by balajisr
Magesh_bala wrote:In Execute command we cant execute the shell script commands, We can call only the shell scripts files.
No.Did you try using Execute command in the first place as suggested by Ray?

Posted: Mon Sep 22, 2008 5:10 am
by ray.wurlod
Magesh_bala wrote:In Execute command we cant execute the shell script commands, We can call only the shell scripts files.
Not true.

If you can prove that your assertion is true I would be interested in seeing the proof.

I execute individual commands through Execute Command activity quite frequently.

Posted: Mon Sep 22, 2008 6:51 am
by chulett
Both the before/after ExecSH commands and the Execute Command stage can execute operating system commands directly as well as scripts.

Posted: Tue Sep 23, 2008 2:21 am
by Magesh_bala
Hi Ray, Thanks for your reply. Whe we execute the command
touch opt/Ascential/Data/Samplefile.txt --> It works

But when we use the Parameter

touch #path#samplefile.txt --> Its not working in Execute command stage

Can you please suggest how to use the parameter in execute command stage.

Thanks and Regards
N.Magesh

Posted: Tue Sep 23, 2008 2:27 am
by ray.wurlod
Where is the parameter coming from?

You can not use parameters in the Command field in the Execute Command stage. You can only use them in the Parameters field.

Therefore the solution that you require for this particular problem (assuming that there exists a job sequence parameter called "path" and that its value includes a terminating pathname delimiter character ("/" on UNIX)) is as follows:

Command: touch
Parameters: #path#samplefile.txt

Posted: Tue Sep 23, 2008 3:22 am
by Magesh_bala
Hi Ray, Can you please tell me the solution.

Posted: Tue Sep 23, 2008 3:57 am
by ray.wurlod
I did. A very complete solution.

Please purchase a premium memberhip that will allow you to read it, or have your employer purchase it.

Premium membership is one of the ways that the hosting and bandwidth costs of DSXchange are defrayed. By taking premium membership you are not only getting the benefits thereof but you are also helping to keep DSXchange alive. At less than 30c (Rs12) per day it is not expensive.

Posted: Fri Oct 31, 2008 10:15 am
by manuel.gomez
ray.wurlod wrote:Where is the parameter coming from?

You can not use parameters in the Command field in the Execute Command stage. You can only use them in the Parameters field.

Therefore the solution that you require for this particular problem (assuming that there exists a job sequence parameter called "path" and that its value includes a terminating pathname delimiter character ("/" on UNIX)) is as follows:

Command: touch
Parameters: #path#samplefile.txt
What if the command 'touch' requires the complete path to be executed?
For example, /pathforcommands/touch

How can I tell Datastege the path where the command is in order to be executed?

Thanks a lot

Posted: Fri Oct 31, 2008 10:32 am
by chulett
Simply put your shell of choice in the command prompt, say "ksh", and then the complete command with whatever parameters you need in the parameter prompt.