【问题标题】:passing parameters to remote beanshell将参数传递给远程 beanshell
【发布时间】:2010-02-08 16:28:15
【问题描述】:

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

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

打电话。

是否可以从script.bsh 中读取参数“p1”、“p2”和“p3”?

附言通过bsh.args 传递的本地参数可以正常工作,但不能用于远程脚本。

【问题讨论】:

    标签: parameter-passing beanshell


    【解决方案1】:

    我想,您正在使用 beanshell 库。根据消息来源,没有办法这样做:该实用程序只接受 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 之前,您需要与远程站点进行额外的通信才能上传此文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-19
      • 1970-01-01
      • 2015-09-10
      • 2021-11-27
      • 2011-02-18
      相关资源
      最近更新 更多