Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

runtime exec

 
Peter Straw
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to run a command line type instruction from within Java, even if the command line isn't a program like word.exe ( I am trying to run a mysqldump command to copy a database from one linux box to another ).
...Is it possible to call a shell script using runtime exec? or is there a better way
TIA
 
Steve Deadsea
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shell scripts are interpretted by a program such as bash. You could call bash with an argument of the shell script.
 
Thomas Smets
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter it depends what you need to do !
For a pure dump, just do as said :
exec(new String(){"/bin/bash", "/home/me/myscript.sh"})
this will be the fastest.
Otherwise you may have a JDBC connection from DB to DB, also !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic