开发者

passing parameters to remote beanshell

I need to pass para开发者_如何学JAVAmeter to remote beanshell script which is run through

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

call.

Is it somehow possible to read params 'p1', 'p2' and 'p3' from within the script.bsh?

p.s. Local params passing through bsh.args works fine, but it's unusable with remote scripting.


I suppose, you are using beanshell library. There is no way to do so, according to sources: the utility takes only 2 arguments: the URL and the local script filename. It even does not support several script filenames, as it claim to.

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 );
    }

Also the server-side should be aware about the arguments passed.

The ways out for you:

  1. Create the script template, in which you will substitute the arguments for the script and save the substitute script to temp dir before passing to bsh.Remote
  2. Create a remote file, where the script can read arguments from. You need additional communication with remote site to upload this file before calling bsh.Remote.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜