• Post Reply 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
  • Quote
  • 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 (I think .sh file) in Linux environment.Thanks in Advance
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can rush the shell (bash) as an interpreter by invoking it and providing a file of shell commands as an argument. So what we might normally enter on a command line to do this:

can be inserted in a Runtime.exec() statement.
 
Marilyn de Queiroz
Sheriff
Posts: 9082
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Matthews,

Please do not cross-post. Pick one forum and post the question there. You may post in other forums and give a link to that one question if you wish.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!