Unix 'expr'-- trying runtime.exec
My shop relies heavily on unix environment variables. I'm trying to mimic the functionality of the 'expr' command in Java so my program will easily fit in. Currently I'm trying to do this using runtime.exec, but I am by no means attached to that method.
I would like to be able to take an expression like '$HOME/cat/dog.java' and turn it into 'theuser/cat/dog/java' .
-I'm looking for a solution compatible with 1.3, if possible
-I've already read "When Runtime.exec Won't", and lots of other articles.
The below code doesn't work since it doesn't seem to be able to view the shell variables. R is a global Runtime.getRuntime():
String expr(String u)throws Exception//Filter a string as a *nix expr
{
Process p = R.exec("expr "+u);
InputStream in = p.getInputStream();
String s="";
int c;
while( (c=in.read()) != -1)
s+=(char)c;
in.close();
p.waitFor();
if(s.length()>0) s=s.substring(0,s.length()-1);//Chop expr's \n
return s;
}
Any help is appreciated. Thank you very much.

