This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Java in General and the fly likes runtime exec Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "runtime exec" Watch "runtime exec" New topic

runtime exec

Peter Straw
Ranch Hand

Joined: Jan 08, 2002
Posts: 79
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
Steve Deadsea
Ranch Hand

Joined: Dec 03, 2001
Posts: 125
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

Joined: Dec 11, 2001
Posts: 111
Peter it depends what you need to do !
For a pure dump, just do as said :
exec(new String(){"/bin/bash", "/home/me/"})
this will be the fastest.
Otherwise you may have a JDBC connection from DB to DB, also !

Thomas Smets
Just another developper
I agree. Here's the link:
subject: runtime exec
It's not a secret anymore!