Runtime.exec issue with quotes
Posted on 2006-07-12
We are implementing a wrapper around a unix utility. It takes multiple parameters and we build the command line and execute from our java code. e.g. Here is what we are trying to execute
/opt/myunixutil/bin/myutil -to emailaddress -data datafilename -subject subject
When we try to pass subject with multiple worlds e.g. Test Data Prices in quotes
/opt/myunixutil/bin/myutil -to email@example.com -data /tmp/datafile -subject 'Test Data Prices',
myutil actually throws back error 'unidentified option Data. So it does not recognize the single quote. If it is executed from command line, it works fine. If we try to change it to "", it does not work as well.
We are using Runtime.exec(String) call and String parameter is build with command mentioned earlier.
Can anyone help us out addressing this issue.
Thanks in advance