我可以自动发现 shell 或 Perl 脚本的参数到“元”吗? 为他们编程 WEB UI?

发布于 2024-07-12 09:58:33 字数 336 浏览 6 评论 0原文

是否可以自动发现 shell/Perl 脚本的参数,以便为它们“元”编程 WEB UI?


我有一堆“遗留”脚本,我想对其进行“网络包装”。 到目前为止,我已经创建了一个带有大约 3 个参数的 CGI-BIN Web 应用程序,可以调用 bash/Perl 报告脚本。

但现在我想到也许有更快或自动的方法来包装这 100 个脚本。

所以基本上我想了解元编程技术,在这些技术中我会发现特定的 bash 或 Perl 脚本采用哪些输入参数,然后使用这些输入参数生成相应的 HTML FORM 元素,如 TEXT INPUT 或 SELECT 下拉框等

。想法或示例链接?

Is it possible to auto-discover parameters to shell/Perl scripts in order to "meta" program WEB UIs for them?


I have a bunch of "legacy" scripts that I'd like to "web wrap".
So far I have created a CGI-BIN web app with about 3 parameters that can call a bash/Perl reporting script.

But it now occurs to me maybe there is quicker or automatic way to wrap these 100s of scripts.

So basically I'd like to find out about techniques for metaprogramming where I'd discover what input parameters a particular bash or Perl script takes and then generate corresponding HTML FORM elements with those input parameters as TEXT INPUT or SELECT dropt down boxes etc.

Any ideas or links to examples?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

岁月染过的梦 2024-07-19 09:58:33

没有办法查看随机的 Perl 源代码来确定它采用什么参数、这些参数的含义或它们是如何约束的。

如果您处理的 Perl 脚本都使用通用库来处理参数,例如 GetOpt::Long ,那么您可以使用脚本传递给参数处理器的信息来获取大部分信息。

除此之外,你就不走运了。

There isn't a way to look at random Perl source code to determine what arguments it takes, what those arguments mean, or how they are constrained.

If the Perl scripts you deal with all use a common library to process arguments, such as GetOpt::Long, then you could use the information the script passes to the argument processor to get most of the information.

Other than that, you're out of luck.

旧情别恋 2024-07-19 09:58:33

除了 Catalyst 之外,CGI 还有一种通过 GET 或 POST 发送参数的标准方法,并且 CGI.pm 让一切变得简单


您添加了要求“我想了解元编程技术,在这些技术中我会发现特定 bash 或 perl 脚本采用哪些输入参数,然后使用这些输入参数作为 TEXT INPUT 或 SELECT drop 生成相应的 HTML FORM 元素下箱子等”

没有一种标准方法可以“发现特定 bash 或 perl 脚本采用哪些输入参数”,因为这些脚本没有报告此信息的标准方法。 有接近标准的可能性(解析相应手册页的 troff 源,使用“--help”调用脚本并解析输出),或者您可以将此信息保存在某种数据库中。

有一种标准方法可以确定哪些参数发送到 CGI 脚本,然后将这些参数显示为可设置的表单元素。 CGI.pm 会将它们作为哈希引入,您可以循环遍历(将键显示为文本框的标签,将值显示为相应文本框中的文本)。

Aside from Catalyst, CGI has a standard way to send in parameters via GET or POST, and CGI.pm makes it easy.


You've added the requirement "I'd like to find out about techniques for metaprogramming where I'd discover what input parameters a particular bash or perl script takes and then generate corresponding HTML FORM elements with those input parameters as TEXT INPUT or SELECT drop down boxes etc."

There isn't a standard way to "discover what input parameters a particular bash or perl script takes" because there isn't a standard way for these scripts to report this information. There are close-to-standard possibilities (parsing the troff source of the corresponding man page, calling the script with "--help" and parsing the output), or you could keep this information in a database of some sort.

There is a standard way to determine which parameters were sent to a CGI script, and then display those parameters as settable form elements. CGI.pm will bring them in as a hash, which you can loop through (displaying the key as the label for your text box and the value as the text in the corresponding text box).

惯饮孤独 2024-07-19 09:58:33

为了扩展 brian 所说的内容,如果您能为我们提供一些代码示例,我们也许可以提供更多帮助。 如果脚本使用相同(或相似)的方法来解析其参数,那么我们就有机会编写一些代码。

您很可能可以为“常规”遗留脚本部分编写元编程解决方案,并为“不规则”脚本编写基于表的解决方案。

To expand on what brian said, if you can provide us a few code samples, we can maybe help a little more. If the scripts use the same (or similar) methods for parsing their parameters, then we have a chance to write some code.

It may well be that you can write a meta-programming solution for the portion of your legacy scripts that are "regular", and write a table-based solution for the "irregular" ones.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文