Reputation: 34071
I have following shell statement:
gs -q -dNODISPLAY -c "(/Users/developer/Desktop/1449367569_Concurrency.pdf) (r) file runpdfbegin pdfpagecount = quit"
and want to execute in elixir with the system.cmd
function. I tried as follow:
System.cmd("gs", ["-q", "-dNODISPLAY", "-c \"(/Users/developer/Desktop/1449367569_Concurrency.pdf) (r) file runpdfbegin pdfpagecount = quit\""])
But it does not work at all. The output is just nothing.
Upvotes: 0
Views: 416
Reputation: 222108
In the original command you posted, the shell will pass 4 arguments to gs
:
-q
-dNODISPLAY
-c
(/Users/developer/Desktop/1449367569_Concurrency.pdf) (r) file runpdfbegin pdfpagecount = quit
The double quote around (/Users/developer/Desktop/1449367569_Concurrency.pdf) (r) file runpdfbegin pdfpagecount = quit
is not passed to gs
; it's just part of the shell's syntax, useful for when you want to include a space character in an argument. For example echo "foo"
will print just foo
, not "foo"
.
So you need to split -c
and the rest into separate strings, and not include the double quote in the last argument:
System.cmd("gs", ["-q", "-dNODISPLAY", "-c", "(/Users/developer/Desktop/1449367569_Concurrency.pdf) (r) file runpdfbegin pdfpagecount = quit"])
Upvotes: 1