Does anyone know if it is possible to call a shell script from within Java program and also pass an argument to that shell script from the for loop of that java class? In my shell script I am setting MySQL system variables to different values to see if those values affect the performance of the database application. I could have set those values through JDBC, but as I am working with MySQL, it is not possible to restart the database from JDBC, after each query execution.
Asked
Active
Viewed 95 times
2 Answers
0
Yes it is possible. For something like this you would probably be better off just using a batch file or something to do it though.
If you really do need to use java try:
0
Runtime.exec()
is what you are looking for.
Runtime.getRuntime().exec("theScript.sh param1 param2);
..modulo exception handling.
You may want to look into Apache Commons

Jiri Kremser
- 12,471
- 7
- 45
- 72