I have a program which calls a shell command. When I executes the command using java's run.exec, it is not working but when I executes the command directly in terminal, it works like charm.
ex: pdf2swf "3bbba47.pdf" -T 9 -o "3bbba47.swf" didnt worked
from java program but worked directly executing it in terminal.
But when I tried removing the quotes from the command
pdf2swf 3bbba47.pdf -T 9 -o 3bbba47.swf
It worked fine in both run.exec and terminal.
Why is it so?
I tried in both mac and ubuntu and ended with same result.
run.exec() does not invoke the shell. The shell parses the command line and effectively removes the quotes before passing them as arguments to pdf2swf. You can only run "raw" commands with run.exec().
You can, if you want, run the shell with run.exec(), and have it parse your command as a shell command. Quoting will be a bit painful, but doable.