Re: Executing command with Runtime.getRuntime.exec() fails



On 29 Nov., 16:30, Nigel Wade <n...@xxxxxxxxxxxx> wrote:
Ingo Menger wrote:
On 29 Nov., 13:23, Lionel <lione...@xxxxxxxxx> wrote:

I did in fact try using exec(String[]) but perhaps I tokenized it
incorrectly. This is what I tried:

String mysqlServiceCommand[] = {"cmd", "/c",
"C:\\Program Files\\MySQL\\MySQL Server 5.0\\bin\\mysqld-nt.exe\"",
"--install", "MySQL1",
"--defaults-file=\"C:\\Program Files\\MySQL\\MySQL Server " +
"5.0\\my-large.ini\""};

What is the "cmd /c" for, except to make the program less portable?
I think one can trust that Runtime.exec will choose the right command
interpreter.

No, it definitely will not.

I just read the API docs and find out to my surprise that you're
right.

I didn't also know that Runtime.exec indeed does tokenization which
makes things more, not less, complicated and does not make any sense,
IMHO.

exec() will run exactly what you tell it to run.

Sure. In this case
cmd /c C:\Program Files\... further args ...


If
you don't explicitly include cmd.exe then it will not run cmd.exe.

Too bad for the "run anywhere" approach. Especially when directory
names contain spaces.
.



Relevant Pages

  • Re: Executing command with Runtime.getRuntime.exec() fails
    ... I think one can trust that Runtime.exec will choose the right command ... interpreter. ... If that executable is not a shell, ...
    (comp.lang.java.programmer)
  • Re: SID History and SID Filtering questions (netdom)
    ... group policies rebooted the lab DC's and tried the command, netdom ... ... Oh and by the way the Technet doc on how to create a SID mapping file ... SID filtering is enabled automatically on any trust relationships created by domain controllers running Windows 2000 Service Pack 4 or Windows Server 2003. ...
    (microsoft.public.windows.server.migration)
  • Re: Completed my programming language overview with a BASIC for CP/M page also
    ... opinion on bywater basic - their should be a cp/m version ... The Bywater BASIC Interpreter implements a large ... It also offers shell programming facilities ... a shell command can be entered interactively at the ...
    (comp.os.cpm)
  • Re: Unable to create domain trust: a device not functioning
    ... These errors happen randomly and not in response to running the trust setup. ... The repadmin command you gave me showed the last attempted replication ... Reading LSA domain policy information ... Establishing a session with \\digitaldata2.ferraricolor.com ...
    (microsoft.public.windows.server.active_directory)
  • The system detected a possible attempt to compromise security
    ... We were have issues with a tree in one of our Forests. ... although it would claim to validate in Domain & Trust MMC. ... became suspect to the root domain. ... so the command, run from the ROOT domain, looked like this ...
    (microsoft.public.windows.server.active_directory)