Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » exec command from Eclipse
exec command from Eclipse [message #220819] Wed, 11 July 2007 01:39 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: exec command from Eclipse [message #220835 is a reply to message #220819] Wed, 11 July 2007 07:29 Go to previous message
Guenther Koegel is currently offline Guenther KoegelFriend
Messages: 56
Registered: July 2009
Member
Loc Le wrote:
> Hi All,
> ...
> 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

Hi Loc Le,

the redirection (">")is not handled by the Java runtime, it's a feature
of the command line interpreter. Either do the redirection yourself or
start the command line interpreter and give your command as argument, e.g.

cmd /c "C:\Program File\.... > D:\\file1.dump"

which could cause some extra work on quoting.

Bye

Günther
Previous Topic:Publish WSDL to IIS without UDDI
Next Topic:Managed Make doens't create a makefile
Goto Forum:
  


Current Time: Thu Apr 25 14:44:05 GMT 2024

Powered by FUDForum. Page generated in 0.08950 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top