reading a file from unix server into a variable

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

Post Reply
altruist
Participant
Posts: 73
Joined: Thu May 11, 2006 6:50 am

reading a file from unix server into a variable

Post by altruist »

Hi Everyone,


In routines, i am using

Code: Select all

      UnixCmd="cat ""\PATH":"Filename"
Call DSU.ExecSH(UnixCmd,Error)

I need to have the value read from the file in order to return it from routine. So taht I can use it in my jobs.

How can I get the result of the executed command

Thanks a Lot
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Code: Select all

UnixCmd="cat ""\PATH":"Filename" 
Call DSExecute("UNIX", UnixCmd,ScreenOutput, ReturnCode)
ScreenOutput will be a dynamic array, where every line in the output is a line in the array. Read up on DSExecute in your DS BASIC manual.
Last edited by kcbland on Thu Jun 08, 2006 9:22 am, edited 1 time in total.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
altruist
Participant
Posts: 73
Joined: Thu May 11, 2006 6:50 am

Post by altruist »

I used the following code

Code: Select all

$INCLUDE DSINCLUDE JOBCONTROL.H

dump=Arg1
Ans=0

      UnixCmd="cat /nz/etl/dev/wrk/pwd_mms_etlext"
      Call DSU.DSExecute("UNIX",UnixCmd,SystemOutput,ErrCode)
Ans=SystemOutput
But it gives the following errors

Code: Select all

Program "DSU.TryUnix": Line 8, Unable to open the operating system file "DSU_BP.O/DSU.DSExecute".
[ENOENT] No such file or directory
Program "DSU.TryUnix": Line 8, Unable to load file "DSU.DSExecute".
Program "DSU.TryUnix": Line 8, Unable to load subroutine.
Anything wrong with what i am doing???????
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Just call DSExecute from your routine.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Oops, I corrected the original post, you don't need the INCLUDE statement you added as well.
Last edited by kcbland on Thu Jun 08, 2006 12:15 pm, edited 1 time in total.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
altruist
Participant
Posts: 73
Joined: Thu May 11, 2006 6:50 am

Post by altruist »

what is the difference between DSU and without DSU?

Thought for any datastage provided routines we need to use DSU.

Its working right now

Thanks
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

altruist wrote:what is the difference between DSU and without DSU?
Functions need a declaration, but DSExecute is a Routine and therefore CALL'ed. Custom functions using other custom functions or job control API functions need the INCLUDE and DEFFUN statements. Custom subroutines are actually saved with a "DSU." prefix.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Supplied functions (those in on-line help and manuals) don't need a prefix.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply