Name: stC104175 Date: 08/23/2000
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
Runtime.exec(String) and Runtime.exec(String, String[]) do not consider the
significance of single and double quote characters when parsing the command-line
string. Right now they parse "xterm -T 'My title' -e ls" as follows:
xterm
-T
'My
title'
-e
ls
such that each line denotes another element in the array ARGV[]. Instead, the
above String should be parsed as:
xterm
-T
My title
-e
ls
Another thing worth noting is that this parsing behavior should be different
under Windows and Unix-based machines as Unix-based machines accept single and
double quotes equaly and Windows-based machines only accept double-quotes.
If you would like me to provide you with the source-code to correct this bug,
please contact me.
(Review ID: 107860)
======================================================================
Name: krC82822 Date: 03/14/2001
>java -version
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)
exec cannot handle commands with "-" parameters.
Below code executes nbtstat with -n parameter.
Output dataset does not get updated with command output.
Command works under C++ and NT Command Prompt.
button12.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
Runtime r = Runtime.getRuntime();
try {
r.exec("c:\\windows\\system32\\nbtstat -n > c:\\temp\\tmp.rpt");
}
catch (java.io.IOException e)
{ System.out.println("Got exception on button Nbtstat Names " +
e);
e.printStackTrace();
}
}
});
Commands with "/" parameters work fine:
Below code executes mem with /d parameter.
button11.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
Runtime r = Runtime.getRuntime();
try {
r.exec("c:\\windows\\system32\\mem.exe /d > c:\\temp\\tmp.rpt");
callWord();
}
catch (java.io.IOException e)
{ System.out.println("Got exception on button Memory Debug " +
e);
e.printStackTrace();
}
}
});
Workaround is to place command in a script file:
button12.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
Runtime r = Runtime.getRuntime();
try {
r.exec("c:\\joe\\java\\bin\\nbtstat_n.bat");
// r.exec("c:\\windows\\system32\\nbtstat -n > c:\\temp\\tmp.rpt");
callWord();
}
catch (java.io.IOException e)
{ System.out.println("Got exception on button Nbtstat Names " +
e);
e.printStackTrace();
}
}
});
where nbtstat_n.bat contains:
c:\\windows\\system32\\nbtstat -n > c:\\temp\\tmp.rpt
(Review ID: 118798)
======================================================================
- duplicates
-
JDK-4109888 (process spec) Semantics of external process is not defined in JLS
- Closed