Deleting a file from DataStage server routine

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
arnabdey
Participant
Posts: 50
Joined: Wed Jan 10, 2007 5:56 am

Deleting a file from DataStage server routine

Post by arnabdey »

Can anyone please tell how to delete a file from DataStage server routine. This routine needs to be able to run on UNIX as well as WINDOWS environment.
Arnab
us1aslam1us
Charter Member
Charter Member
Posts: 822
Joined: Sat Sep 17, 2005 5:25 pm
Location: USA

Post by us1aslam1us »

Are we talking about hashed file or flat file as commands will differ from one environment to other. Also why don't you just use Execute command stage or just filter command(if flat file) in sequential file stage?
I haven't failed, I've found 10,000 ways that don't work.
Thomas Alva Edison(1847-1931)
arnabdey
Participant
Posts: 50
Joined: Wed Jan 10, 2007 5:56 am

Hi us1aslam1us

Post by arnabdey »

I actually have a server routine with many other things. The requirement is to delete a mere flat file at the end. So I was looking for a Basic command.

[quote="us1aslam1us"]Are we talking about hashed file or flat file as commands will differ from one environment to other. Also why don't you just use Execute command stage or just filter command(if flat file) in sequential file stage?[/quote]
Arnab
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

You're going to need to find the SYSTEM call that tells you the O/S and then build the command appropriately. Difference would be the actual command used and the direction of the slashes. Primarily. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

For a flat file you can use the following. File is the input argument that will be the fully qualified name of the file to be removed.

Code: Select all

      FUNCTION RemoveFile(File)

      IF system (91)
      THEN
         OS="NT"
         CMD="del ":File
      END
      ELSE
         OS="UNIX"
         CMD="rm ":File
      END

      Call DSExecute(OS, CMD, Output, RtnCd)
      Ans=RtnCd
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
arnabdey
Participant
Posts: 50
Joined: Wed Jan 10, 2007 5:56 am

Hi DSguru

Post by arnabdey »

Hi DSguru

But say I use Windows 2000 or 2003 as my server, will the system function return 1.

[quote="DSguru2B"]For a flat file you can use the following. [b]File[/b] is the input argument that will be the fully qualified name of the file to be removed.
[code]
FUNCTION RemoveFile(File)

IF system (91)
THEN
OS="NT"
CMD="del ":File
END
ELSE
OS="UNIX"
CMD="rm ":File
END

Call DSExecute(OS, CMD, Output, RtnCd)
Ans=RtnCd
[/code][/quote]
Arnab
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

It should. Someone here needs to confirm that as I am not sitting on a windoze box.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

System(91) is specifically there to answer the Windows/UNIX question.
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