Win a copy of Kotlin in Action this week in the Kotlin forum!
    Bookmark Topic Watch Topic
  • New Topic

How to run a Batch File using java in LINUX Environment  RSS feed

 
Mathews P Srampikal
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Report post to moderator
How to run a Batch File using java in LINUX Environment
For example in windows we can run like as given below.
Process ps=Runtime.getRuntime().exec("cmd.exe /c "C:/runbatch.bat");
How to run the same in Linux environment.Thanks in Advance
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Report post to moderator
I have not tried it, but you can try something like: Runtime.getRuntime().exec("/bin/sh <path to batch file>/yourbatchfile.sh");
You could use other shells (ksh, bash, csh) as well, I guess, just make sure the yourbatchfile is compatible with whatever shell you choose.
 
Marilyn de Queiroz
Sheriff
Posts: 9080
12
  • Mark post as helpful
  • send pies
  • Report post to moderator
Matthews,

Please do not cross-post. Pick one forum and post the question there. You may post here and give a link to that one question if you wish.

Further responses should go in this thread.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!