View previous topic :: View next topic
|
Author |
Message |
Andy85
New User
Joined: 25 Dec 2008 Posts: 35 Location: India
|
|
|
|
I have few PDS (one for each application), containing multiple members with directory paths in those (for FTP purpose). I need to write a job or utility, that would scan through each member in the PDS and find lines having 'cd' command. When such a line is encountered, I need to get the directory path against the cd command, check it against another file (which will have new mappings) and accordingly replace the path within the member from input. I have done some research on File-Aid but it seems like File-Aid can be used effectively only, if the changes to be done have more or less, the same format (in this case paths would be different in each member and hence length of string to be replaced would keep changing). Moreover, I didn't get any option of looking up against another input file. So I think the only other option may be to use REXX commands.
Could anyone please suggest any possible approach? |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
An edit macro might be a better choice than Rexx. However, as you have asked for Rexx...
Read the sorted mappings into stems. Allocate the member to be changed to, e.g., TULUT1. Read each record from TULUT1; search the record for the command (using POS to search for "CD " seems like a good bet to me). If the record needs to be changed, find the directory in the old map stem; get the corresponding new directory from the new map stem. Create an output record by concatenating the beginning and end of the record on either side of the directory. Write the record (changed to not) to a temporary data set or member. When the entire member has been read, copy the temporary over it. |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
I agree an editor macro might be easier. Something like this:
1. exclude all lines
2. FIND 'cd' ALL WORD
3. CHANGE '/old1' '/new1' ALL NX
4. CHANGE '/old2' '/new2' ALL NX
and repeat #3 as needed. That is, move the old and new directories into the macro. This would be a manual cut and paste... not elegant programming, but you could be done in a few minutes.
Then run the macro for each member of each PDS. |
|
Back to top |
|
|
|