how to call an unix script in sequence job

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
sjordery
Premium Member
Premium Member
Posts: 202
Joined: Thu Jun 08, 2006 5:58 am

how to call an unix script in sequence job

Post by sjordery »

Hi all,

Can anybody suggest me how to call a unix script in the job sequence.
In the 1st job I am sending one databas table to a file.
Then I have to call an unix script to operate on that file.
sniper80
Participant
Posts: 3
Joined: Wed Apr 25, 2007 5:23 am
Location: london

Re: how to call an unix script in sequence job

Post by sniper80 »

you can use a execute command stage after the job that loads the data from DB into your file and then to call your .sh along with respective parameters.
ivannavi
Premium Member
Premium Member
Posts: 120
Joined: Mon Mar 07, 2005 9:49 am
Location: Croatia

Post by ivannavi »

...Or you can call your script within the very same job as an "After-job subroutine" (job properties, General tab)
sjordery
Premium Member
Premium Member
Posts: 202
Joined: Thu Jun 08, 2006 5:58 am

Post by sjordery »

Hi ,

I have to perform the sequence job bcz there is another job which will remove one file after executing the script.

In the exec command stage I tried basic unix commands like rm,cp and its working fine,but to execute the unix script while giving sh /data/script1.txt command I am not geting the result.

If I have to use ExecSh after job sub routine then what what parameters I have to pass?

can anybody suggest?
Last edited by sjordery on Wed Apr 25, 2007 7:01 am, edited 1 time in total.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What result are you getting? :?

You don't need the 'sh' part on the front, simply put the fully pathed script in the Command box and then any parameters / arguments (if needed) in the Parameter box.

Run the job and then post whatever messages in the log relate to that stage.
-craig

"You can never have too many knives" -- Logan Nine Fingers
sjordery
Premium Member
Premium Member
Posts: 202
Joined: Thu Jun 08, 2006 5:58 am

Post by sjordery »

Hi Craig,

In the log it is showing that sequence job is finished.
But the script is not getting executed.
I am able to run the script in the unix env and getting the result properly.

This is the log report I am getting.

----------------------------------------------------------------
mail_alert_seq..JobControl (@Execute_Command_11): Executed: /data/skscript
Reply=0
Output from command ====>
cat: skey.txt: No such file or directory.
----------------------------------------------------------------

Its showing skey.txt file not found but file is there and I am able to execute the script in the unix env.

Can you suggest what is wrong here?
Is there any other way to run the script?
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Within the script, use fully qualified paths for any file you write to or reference. Your script is complaining that skey.txt is not present. Ofcourse not, the dsengine will look for this file in its home directory. Your script works from command line because skey.txt might be present in /data/ directory, the same as the script and hence it finds it and the script executes.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
sjordery
Premium Member
Premium Member
Posts: 202
Joined: Thu Jun 08, 2006 5:58 am

Post by sjordery »

I gave full path for the file skey.txt in the unix script.
Then after running the sequence I am getting following log report.

--------------------------------------------------------------------------------
mail_alert_seq..JobControl (@Execute_Command_11): Executed: /data/skscript
Reply=126
Output from command ====>
SH: line 1: /data/skscript: Permission denied
-----------------------------------------------------------------------------
nw its showing permission denied for the script.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Can you execute it from unix using the same id? If yes then try giving the command as

Code: Select all

. /data/skscript 
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
rafik2k
Participant
Posts: 182
Joined: Wed Nov 23, 2005 1:36 am
Location: Sydney

Post by rafik2k »

First give execute permision of the script to the user and check.
You can also check by giving full permision like chmod 777
sjordery
Premium Member
Premium Member
Posts: 202
Joined: Thu Jun 08, 2006 5:58 am

Post by sjordery »

Hi,

Thanks to all.
I gave the command as . /data/script and 777 permission to the script.
Its working fine now.
Post Reply