You are not logged in.
Hi. I think this should be pretty easy, but I just can't. Hopefully somebody could help me.
Simply put: I want to run java command where the argument has a space in filename.
This is my script:
#!/bin/bash
TESTPATH="/home/laite/bin/test dir"
EXEC="java -jar \"$TESTPATH\"/some.js"
echo $EXEC
${EXEC}
and the output:
# laite@laite-arch ~/bin
> ./java_test.sh
java -jar "/home/laite/bin/test dir"/some.js
Error: Unable to access jarfile "/home/laite/bin/test
Last edited by laite (2013-08-06 13:44:05)
Offline
you should use TESTPATH="/home/laite/bin/test\ dir"
EDIT : i've found this http://stackoverflow.com/questions/1214 … -as-a-java
Last edited by andjeng (2013-08-06 08:08:42)
just looking around.
Offline
EXEC="java -jar \"${TESTPATH}/some.js\""
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Offline
Your first line says you're using bash, so... use bash features?
cmd=(java -jar "$jarpath"/some.jar) printf '%q ' "${cmd[@]}"; echo "${cmd[@]}"
Nice, this worked! Thanks.
Edit: And just now I understood why and how it worked. Snappy
Last edited by laite (2013-08-06 16:28:28)
Offline