Execute Unix commands in datastage

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Magesh_bala
Participant
Posts: 86
Joined: Mon Nov 27, 2006 3:42 am
Location: Wilmington

Execute Unix commands in datastage

Post 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?
sachin1
Participant
Posts: 325
Joined: Wed May 30, 2007 7:42 am
Location: india

Re: Execute Unix commands in datastage

Post by sachin1 »

where you want to execute these commands, i mean before/afte job subroutine or in basic code.
hamzaqk
Participant
Posts: 249
Joined: Tue Apr 17, 2007 5:50 am
Location: islamabad

Post 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
Teradata Certified Master V2R5
Magesh_bala
Participant
Posts: 86
Joined: Mon Nov 27, 2006 3:42 am
Location: Wilmington

Post 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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

In job sequences you have the Execute Command activity available. Does that name suggest its possible purpose?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Magesh_bala
Participant
Posts: 86
Joined: Mon Nov 27, 2006 3:42 am
Location: Wilmington

Post by Magesh_bala »

In Execute command we cant execute the shell script commands, We can call only the shell scripts files.
balajisr
Charter Member
Charter Member
Posts: 785
Joined: Thu Jul 28, 2005 8:58 am

Post 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?
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Both the before/after ExecSH commands and the Execute Command stage can execute operating system commands directly as well as scripts.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Magesh_bala
Participant
Posts: 86
Joined: Mon Nov 27, 2006 3:42 am
Location: Wilmington

Post 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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Magesh_bala
Participant
Posts: 86
Joined: Mon Nov 27, 2006 3:42 am
Location: Wilmington

Post by Magesh_bala »

Hi Ray, Can you please tell me the solution.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
manuel.gomez
Premium Member
Premium Member
Posts: 291
Joined: Wed Sep 26, 2007 11:23 am
Location: Madrid, Spain

Post 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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply