Runtime.exec("setenv EOUT_DIR /homes/sharmila/temp");
Gives the following error:
java.io.IOException: java.io.IOException: setenv EOUT_DIR
/homes/sharmila/temp: not found
at java.lang.UNIXProcess.<init>(UNIXProcess.java:143)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Runtime.java:566)
at java.lang.Runtime.exec(Runtime.java:491)
at java.lang.Runtime.exec(Runtime.java:457)
at CommandLine.main(CommandLine.java:32)
What am I doing wrong??
Any hints, please?
TIA,
Sharmila.
> Sharmila.
try using the full path of setenv ie /bin/setenv (I Thing)
--
Justin Fowler
Software Engineer
Several things:
- setenv is not a program, it is a shell builtin. To use a shell
builtin, you need to execute a shell. You could *concievably* do
this instead:
String[] cmd = {
"/bin/tcsh",
"-c",
"setenv EOUT_DIR /homes/sharmila/temp",
};
Runtime.getRuntime().exec(cmd);
- Runtime.exec() executes the command in a child process to the JVM.
There is little point in running a command that does nothing but
change its environment (and then terminates).
- it is not possible for one process to modify the environment of
another. In this case, you are (apparently) attempting to run a
child process and have it modify the environment of the parent.
This will never work.
Perhaps you could explain what you are trying to achieve here...
/gordon
--
[ do not send me private copies of your followups ]
g o r d o n . b e a t o n @ e r i c s s o n . c o m
Thanks again,
Sharmila.
Then you should take a look at (one of) the other version of
Runtime.exec(), specifically:
Runtime.exec(String[] cmdarray, String[] envp)
Which allows you to provide an array of 'NAME=VALUE' environment variables
for the child process.
String[] cmd = {
"your_program",
"an_argument",
"another_argument",
};
String[] environment = {
"EOUT_DIR="/homes/sharmila/temp",
"HOME=/homes/sharmila",
"LIMBURGER=smells bad"
}
Runtime.getRuntime().exec(cmd, environment);
Check the docs at:
http://java.sun.com/j2se/1.4.1/docs/api/java/lang/Runtime.html
- Rob
--
(to email me, remove "warez.")
Please do not send me email copies of newsgroup postings.