我需要将参数传递给 偏僻的 运行的beanshell脚本

java -cp bsh-2.0b4.jar bsh.Remote http://10.0.0.1/beanshell script.bsh p1 p2 p3

称呼。

是否有可能从内部读取参数“p1”、“p2”和“p3” script.bsh?

附注本地参数传递 bsh.args 工作正常,但它无法用于远程脚本。

有帮助吗?

解决方案

我想,你正在使用 豆壳 图书馆。据消息人士透露,这是没有办法做到的:该实用程序仅需要 2 个参数:URL 和本地脚本文件名。它甚至不支持多个脚本文件名,正如它声称的那样。

public class Remote
{
    public static void main( String args[] ) throws Exception
    {
          if ( args.length < 2 ) {
                   System.out.println("usage: Remote URL(http|bsh) file [ file ] ... ");
                   System.exit(1);
          }
          String url = args[0];
          String text = getFile(args[1]);
          int ret = eval( url, text );
          System.exit( ret );
    }

服务器端还应该了解传递的参数。

给你的出路:

  1. 创建脚本模板,您将在其中替换脚本的参数,并将替换脚本保存到临时目录,然后再传递给 bsh.Remote
  2. 创建一个远程文件,脚本可以从中读取参数。您需要与远程站点进行额外的通信才能在调用之前上传此文件 bsh.Remote.
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top