Jakub Zawiślak
Jakub Zawiślak

Reputation: 5512

Using xvfb-run shell command in Elixir

I want to use a node script that uses a xvfb (virtual X server). I have this command:

xvfb-run -a --server-args="-screen 0 1366x768x24" node something.js

which works in the terminal. But when I try to rewrite it to the Elixir:

System.cmd "xvfb-run", ["-a", "--server-args=\"-screen 0 
1366x768x24\"", "node", "something.js"]

then I have error which is saying that I need xvfb. It's the same error that I get when I run just node something.js.

I tried Porcelain:

Porcelain.exec "xvfb-run", ["-a", "--server-args=\"-screen 0 
1366x768x24\"", "node", "something.js"]

but it has the same problem. Maybe I'm not using it properly?

I also tried an erlang's os lib:

"xvfb-run -a --server-args=\"-screen 0 1366x768x24\" node something.js"
|> String.to_charlist
|> :os.cmd
|> to_string

which works better, it doesn't have the xvfb problem, but it get stuck in middle of script without any warnings. The command is not terminating, the node script is just not going further.

I know that I can write small .sh script for that. But it would be nice to get this work in plain Elixir

Ubuntu 12.04

Upvotes: 1

Views: 1786

Answers (1)

Jakub Zawiślak
Jakub Zawiślak

Reputation: 5512

There was a problem with ". I have changed the argument

"--server-args=\"-screen 0 1366x768x24\""

to

"--server-args=-screen\ 0\ 1366x768x24"

and now it works

Upvotes: 1

Related Questions