Creating directories
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 1044
- Joined: Wed Sep 29, 2004 3:30 am
- Location: Nottingham, UK
- Contact:
Creating directories
How can I get my DataStage job to create a directory? Do I have to do this in a Before Job script? I want to get rid of my external scripts that pre-create all the directories used in my jobs, and get every job to create the directories it needs for the files it creates. Any suggestions?
Phil Hibbs | Capgemini
Technical Consultant
Technical Consultant
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
You can do it with a simple before-job command, but a script (or routine) would give you better control (for example checking whether the directory already exists).
For the simple method just use a set of operating system commands in the Input Values field for ExecSH as the before-job subroutine, for example
For the simple method just use a set of operating system commands in the Input Values field for ExecSH as the before-job subroutine, for example
Code: Select all
mkdir #DirPath1# ; mkdir #DirPath2# ; mkdir #DirPath3#
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Premium Member
- Posts: 1044
- Joined: Wed Sep 29, 2004 3:30 am
- Location: Nottingham, UK
- Contact:
I've been thinking about doing something frightfully clever in this area for some time.
I already have two tools that scan a dsx file and build up a list of input and output files (inserting the default parameter values if necessary - we typically don't override parameter values, they are just a convenient place to put constant values). One of these tools also generates "mkdir" statements to create all of the directories that are referenced by any sequential or hashed file stages.
I could use this data to feed back into the job design, stuffing the results of the scan back into the dsx file in the Before Job area. That would require periodic re-runs of the scan/stuff/import process.
Alternatively, I could load the file onto the server and use it as the driver of the process, so every job would have a Before Job routine that opens up the file, searches for its own job name, and creates the directories that it finds in the file. It could go further than this and check that all of the input files are present, but I don't know if there's anything that it could do about it at that stage - is it feasible for a Before Job routine to deliberately abort the job? Or, for it to wait for one or more files to be created? I'll take a look at DSWaitForFile.
I already have two tools that scan a dsx file and build up a list of input and output files (inserting the default parameter values if necessary - we typically don't override parameter values, they are just a convenient place to put constant values). One of these tools also generates "mkdir" statements to create all of the directories that are referenced by any sequential or hashed file stages.
I could use this data to feed back into the job design, stuffing the results of the scan back into the dsx file in the Before Job area. That would require periodic re-runs of the scan/stuff/import process.
Alternatively, I could load the file onto the server and use it as the driver of the process, so every job would have a Before Job routine that opens up the file, searches for its own job name, and creates the directories that it finds in the file. It could go further than this and check that all of the input files are present, but I don't know if there's anything that it could do about it at that stage - is it feasible for a Before Job routine to deliberately abort the job? Or, for it to wait for one or more files to be created? I'll take a look at DSWaitForFile.
Phil Hibbs | Capgemini
Technical Consultant
Technical Consultant
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact: