exec command from Eclipse [message #220819] |
Wed, 11 July 2007 01:39 |
Eclipse User |
|
|
|
Originally posted by: nice_neat_guy.yahoo.ca
Hi All,
I use Eclipse as the IDE for my small program. I use mySql as the database
underneath.
What I want is to create a backup database file.
From the command line I run the following command:
"C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqldump.exe" --user root
--password=admin myDatabase > D:\file1.dump
This command works fine and creates the dump file.
Then I plug in this command file in my java program as below:
===================================================
String command = "\"" + "C:\\Program Files\\MySQL\\MySQL Server
5.0\\bin\\mysqldump.exe" + "\"";
com += " --user root --password=admin myDatabase > D:\\file2.dump";
System.out.println(" Command = " + command);
try {
Process proc = Runtime.getRuntime().exec(command);
} catch (Exception e) {
System.err.println(e.toString());
System.err.println(" EXCEPTION");
e.printStackTrace();
}
====================================================
The problem is it did not create the dump file, neither did it throw any
exception. it seemed to run normally, but it didn't because there was no
dump file created.
Note that I use System.out.print to print out the command and verified
that it is correct.
Would you please tell me where the error could be?
Thank you very much
Loc
|
|
|
Re: exec command from Eclipse [message #220828 is a reply to message #220819] |
Wed, 11 July 2007 06:46 |
Eclipse User |
|
|
|
Originally posted by: mknauer.innoopract.com
Hi Loc,
I guess (and that really means *not knowing*, just *guessing*) that your
problems is cause by the STDOUT redirection at the end. Did you try it
with '--result-file=file'?
Another reason could be the blank in the program file path, even if its
surrounded by quotes. I would omit this potential problem by putting the
parameters into a String array and using this exec method
Runtime.getRuntime().exec( String[] cmdarray )
Markus
Loc Le wrote:
> Hi All,
> I use Eclipse as the IDE for my small program. I use mySql as the database
> underneath.
> What I want is to create a backup database file.
> From the command line I run the following command:
> "C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqldump.exe" --user root
> --password=admin myDatabase > D:\file1.dump
>
> This command works fine and creates the dump file.
>
> Then I plug in this command file in my java program as below:
> ===================================================
> String command = "\"" + "C:\\Program Files\\MySQL\\MySQL Server
> 5.0\\bin\\mysqldump.exe" + "\"";
> com += " --user root --password=admin myDatabase > D:\\file2.dump";
>
> System.out.println(" Command = " + command);
>
> try {
> Process proc = Runtime.getRuntime().exec(command);
> } catch (Exception e) {
> System.err.println(e.toString());
> System.err.println(" EXCEPTION");
> e.printStackTrace();
> }
> ====================================================
>
> The problem is it did not create the dump file, neither did it throw any
> exception. it seemed to run normally, but it didn't because there was no
> dump file created.
> Note that I use System.out.print to print out the command and verified
> that it is correct.
>
> Would you please tell me where the error could be?
>
> Thank you very much
> Loc
|
|
|
|
Powered by
FUDForum. Page generated in 0.08950 seconds