Running beanshell script from command line on Windows

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Running beanshell script from command line on Windows

How can I set up Windows to run my beanshell script from command line, properly passing the arguments?
Here is waht I want. Let say, I have myscript.bsh that takes some arguments, so I want to run it in a standard way:

     myscript.bsh <arg1> <arg2> ...

I know it is quite simple in Linux, just by adding the first line as "#!<java path> bsh.Interpreter", assuming that bsh.jar is in the classpath (I found that the best way for this is to put the jar in .../jre/lib/ext).

Note: you cannot have "#!<java path> -cp <bsh jar path> bsh.Interpreter", because Linux will pass the whole line to java executable as one argument, including spaces, and this does not work.

This did not quite work in Cygwin (I think, because of the windows path style issue), so I wrote a simple C program that serves as an interpreter. It actually can be configured to run not only beanshell under java, but virtually anything. It works on Linux too. This way I can have my scripts looking exactly the same on Linux or Cygwin. I can share the program if anybody is interested.

However, on Windows I was not able to solve the problem. I figured out how to tell it to use specified program to open bsh files (tried to use my C program), but here is the issue: arguments for the script are lost.

I know very little about Windows programming, need help.

Any ideas?