多行替换
我正在尝试在多个 JCL 中执行搜索替换,但我需要多行功能,我需要替换多个行。 示例:
//STEP1 EXEC PGM=DUMY,PARAM=XPTO
转换为
//STEP1 EXEC PGM=WORKS,PARAM=THAT
//SOMEDD DSN=DSN.WITH.SOMETHING
//SYSTIN
SOME MORE PARAMETERS
我研究了文件辅助批处理,但它似乎只支持 STRING 替换,而不支持多行。 我认为 REXX 可能会这样做,但我对此一无所知。
有什么想法吗?
I'm trying to perform a search-replace in several JCLs but I need multi-line capabilities, I need to replace a line for several.
Example:
//STEP1 EXEC PGM=DUMY,PARAM=XPTO
transform into
//STEP1 EXEC PGM=WORKS,PARAM=THAT
//SOMEDD DSN=DSN.WITH.SOMETHING
//SYSTIN
SOME MORE PARAMETERS
I looked into file-aid batch processing but it seems to only support STRING replacement without multi-line support.
I thing REXX might do it but I have no knowledge in it.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有一些商业产品可以理解 JCL 语法并可以执行此类操作。 JOB/SCAN 是其中之一,我相信还有其他在这个产品领域也可以做到。
如果您没有这样的产品,这没有任何帮助,所以我们回到您的 Rexx 评论。是的,您可以使用 Rexx 来完成此操作,但您将解析 JCL。根据您的要求,这可能并不简单。 Rexx 没有正则表达式匹配,而这是解析时通常使用的。这是可以完成的,如果您不打算做任何比您所指示的更复杂的事情,那么对于 Rexx 程序员来说可能并不太难 - 也许这是成为一名程序员的机会。 Rexx 的设计目标之一是让编程变得更容易。
另一种方法是使用 Perl,将 PDS 成员复制到 Unix 文件系统,以便可以处理它们,然后在完成后将它们复制回来。假设您正在运行 z/OS 的相对最新版本,并且您的系统程序员已经安装了 Perl 的 z/OS 端口,这是一个免费项目。
如果您愿意将受影响的成员复制到 Unix 文件系统,您可以使用 awk。我只接触过 awk,但它的优点是默认存在,没有人需要安装默认情况下不存在的任何东西(Perl)。
There are commercial products that understand JCL syntax and can do this sort of thing. JOB/SCAN is one, I'm sure others in this product space can do it too.
Which is of no help if you don't have such a product, so we're back to your Rexx comment. Yes, you can do this with Rexx, but you're going to be parsing JCL. This can be non-trivial depending on your requirements. Rexx doesn't have regular expression matching, which is what one normally uses when parsing. It can be done, and if you aren't seeking to do anything much more complicated that what you've indicated then it's probably not too difficult for a Rexx programmer - perhaps this is an opportunity to become one. Rexx had, as one of its design goals, to make programming easier.
An alternative would be to use Perl, copying the PDS members to the Unix file system so you can process them, then copying them back when you're done. Presuming you're running a relatively current release of z/OS and your Systems Programmer(s) have installed the z/OS port of Perl, which is a no-cost item.
If you're willing to copy the affected members to the Unix file system, you may be able to do this with awk. I've only dabbled with awk, but it has the advantage of just being there by default, no one would have to install anything (Perl) that isn't already there by default.
以下是我想到的可能性:
但您可能会遇到一些挑战,当然这些挑战是可以避免的。
如果您搜索的内容同时存在一些其他参数怎么办?就像
//STEP1 EXEC PGM=DUMY,PARAM=XPTO,PARM1='X'
如果搜索字符串跨越多行怎么办?就像
//STEP1 EXEC PGM=DUMY,
// PARAM=XPTO
Here are the possibilities that I have in my mind:
But here are some challenges you would have and of course are avoidable.
What if some other parameters exist along with what you search for? like
//STEP1 EXEC PGM=DUMY,PARAM=XPTO,PARM1='X'
What if the search string is spanned across more than one line? like
//STEP1 EXEC PGM=DUMY,
// PARAM=XPTO
这是一个简单的 TSO/ISPF 编辑宏,将实现您的示例。当然,这非常粗糙,但可以作为如何编辑 JCL 的示例。
Here is a simple TSO/ISPF edit macro that will implement your example. Of course this is very crude but serves as an example of how JCL might be edited.