0

我需要将参数传递给运行的远程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

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

4

1 回答 1

0

我想,您正在使用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.
于 2010-02-08T16:56:56.670 回答