# Write batch to jython scripts



## potchi (May 12, 2011)

Hi!

I have a batch file (potchi.bat) that contains the lines
...
set maxHeap = 2048
set initialHeap = 512
...
and I want to pass these values to a jython script (myScript.py)
such that

AdminTask.setJVMMaxHeapSize('[-serverName myServer -nodeName myNode -maximumHeapSize %maxHeap%]')
AdminTask.setJVMInitialHeapSize('[-serverName myServer -nodeName myNode -initialHeapSize %initialHeap%]')

Thanks!!!


----------



## Squashman (Apr 4, 2003)

While I am not familiar with jython code, most scripting languages accept command line arguments. You will just need to figure out how to parse the command line arguments in your jython code so that you can set the appropriate variables.

You can CALL your jython script from your potchi.bat file just like I did when I wrote that other batch file that then called potchi.bat and sent two variables to it. It is no different. You will just need to figure out the jython code to parse the command line arguements.

http://jythonpodcast.hostjava.net/jythonbook/chapter8.html


----------



## potchi (May 12, 2011)

I can't call a jython script (myScript.py) from potchi.bat, maybe the CALL command works only for .bat extensions


----------



## potchi (May 12, 2011)

I'm also having a hard time on figuring out the jython code to parse the command line arguments


----------



## Squashman (Apr 4, 2003)

potchi said:


> I can't call a jython script (myScript.py) from potchi.bat, maybe the CALL command works only for .bat extensions


Dont' use the CALL command. Just execute it from your batch file.


```
set maxHeap = 2048
set initialHeap = 512
"c:\path\myScript.py" %maxHeap% %initialHeap%
```
Or use the START command to execute the jython script and have the batch file continue it code.

```
set maxHeap = 2048
set initialHeap = 512
start "" "c:\path\myScript.py" %maxHeap% %initialHeap%
```


----------



## Squashman (Apr 4, 2003)

potchi said:


> I'm also having a hard time on figuring out the jython code to parse the command line arguments


Can't help you there.


----------



## potchi (May 12, 2011)

Hi,

I tried this code

set maxHeap=2048
set initialHeap=512
"myFullpathHere\myScript.py" %maxHeap% %initialHeap%

but a pop up Windows box open up
saying

Windows cannot open this file:

File: myScript.py

To open this file, Windows need to know what program created it. Windows can go online to look it up automatically, or you can manually select from a list of programs on your computer

and you have two options below


----------



## Squashman (Apr 4, 2003)

I guess I cannot assume you even know how to run a jython script. But I figured you did.
I want you too reread the link I posted above and look at how they are running their jython scripts from the command line. What are you missing?

Why are you going through this whole process of using a batch file to assign those 2 variables and then passing them to the jython script. Why don't you just have the jython script read the properties file?


----------

