2010-02-08 62 views
0

我需要参数传递到通过参数传递到远程的BeanShell

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

调用运行远程 BeanShell的脚本。

是否可以从script.bsh内读取参数'p1','p2'和'p3'?

p.s.通过bsh.args的本地参数可以正常工作,但对远程脚本无法使用。

回答

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之前,您需要与远程站点进行额外的通信以上载此文件。