Reading file from different folder

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
mahi_mahi
Charter Member
Charter Member
Posts: 45
Joined: Mon Aug 01, 2005 10:02 am

Reading file from different folder

Post by mahi_mahi »

Hi All,
My datastage designer project folder connected to a folder A under unix
so if i write DS routine to read unix file under folder A it is opening/reading
with out any problem......

Suppose if i tried to access different file from differnt folder say
folder chcprov am not able to access......i have tried with OPENPATH
with SSelect but i could not succeeded....

could you please provde me with some exaample syntax it will be much helpful for beginner like me

i tried use command
CALL DSExecute'UNIX','cd /chcprov;ls ':Inputfil,Output,SYSRET)

but after this when am reading file still it is pointing to folder A only

please give me some help

Mahi
sivatallapaneni
Participant
Posts: 53
Joined: Wed Nov 05, 2003 8:36 am

Post by sivatallapaneni »

Are you using the same file handle or different?
You might have to close the first handle if the file handle name is same.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Post your code. You definitely don't need a cd command. Further, DSExecute opens a new shell (in which your cd command would be performed) - that shell closes before DSExecute returns.

Please specify exactly what you're trying to achieve. Is it, for example, to read all files in a folder? You will need to open the file using OpenSeq (which can use a pathname), or to open the folder using OpenPath and read the entire file as a single tring using Read.

Code: Select all

OpenSeq "/chcprov":InputFil To filevariable
Then
   Loop While ReadSeq Line From filevarilable
      * process current line in file
   Repeat
End
CloseSeq filevariable

Code: Select all

OpenPath "/chcprov" To filevariable
Then
   Read FileContents From filevariable, InputFil
   Then
      * statements to process string
   End
   Else
      * file could not be read
   End
   Close filevariable
End
But I'm not clear why there's a SSELECT statement involved (unless it's read all files in a folder). So, please post your code.
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