Deleting a file from DataStage server routine
Moderators: chulett, rschirm, roy
Deleting a file from DataStage server routine
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
-
- Charter Member
- Posts: 822
- Joined: Sat Sep 17, 2005 5:25 pm
- Location: USA
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)
Thomas Alva Edison(1847-1931)
Hi us1aslam1us
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]
[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
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.
Hi DSguru
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]
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
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: