S
Steve Rainbird
I am trying to use Runtime.exec to run a command and pass it a parameter.
I need it to preserve the spaces in the parameter but cannot get it to work.
E.g
My code says
String cmd = "sh1 xxxx 1234";
Process child = Runtime.getRuntime().exec(cmd);
the sh1 bash shell says
echo '$@' = $@
echo '$1' = $1
echo '$2' = $2
When I run it it displays
$@ = xxxx 1234
$1 = xxxx
$2 = 1234
I want it to pass the code "as is" so as one parameter
So it would display
$@ = xxxx 1234
$1 = xxxx 1234
$2 =
I could even cope with
$@ = xxxx 1234
$1 = xxxx
$2 = 1234
I have tried different variation of single and double quotes without any
success.
I need it to preserve the spaces in the parameter but cannot get it to work.
E.g
My code says
String cmd = "sh1 xxxx 1234";
Process child = Runtime.getRuntime().exec(cmd);
the sh1 bash shell says
echo '$@' = $@
echo '$1' = $1
echo '$2' = $2
When I run it it displays
$@ = xxxx 1234
$1 = xxxx
$2 = 1234
I want it to pass the code "as is" so as one parameter
So it would display
$@ = xxxx 1234
$1 = xxxx 1234
$2 =
I could even cope with
$@ = xxxx 1234
$1 = xxxx
$2 = 1234
I have tried different variation of single and double quotes without any
success.