Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Works with Nerves #40

Closed
joserpintuitivo opened this issue Nov 24, 2022 · 3 comments
Closed

No Works with Nerves #40

joserpintuitivo opened this issue Nov 24, 2022 · 3 comments

Comments

@joserpintuitivo
Copy link

iex(3)> MuonTrap.cmd("echo", ["hello"])
** (ErlangError) Erlang error: :enoent
    (muontrap 1.0.0) lib/muontrap/options.ex:52: MuonTrap.Options.validate("echo", ["hello"], [])
    (muontrap 1.0.0) lib/muontrap.ex:99: MuonTrap.cmd/3
    iex:3: (file)
@joserpintuitivo
Copy link
Author

joserpintuitivo commented Nov 24, 2022

with cmd it only works, because with the MuonTrap it doesn't?

iex(3)> cmd("echo hello")
hello
0

@joserpintuitivo
Copy link
Author

iex(1)> System.cmd("echo", ["hello"])
** (ErlangError) Erlang error: :enoent
    (elixir 1.12.3) lib/system.ex:1041: System.cmd("echo", ["hello"], [])

@fhunleth
Copy link
Owner

Nerves has a very limited set of Linux utilities available. You found an interesting case where echo is not available. However, it's possible to still use echo as a built-in shell command.

To see what's available, run ls on /bin and /usr/bin. Here's what I get:

iex(1)> ls "/bin"
ash         busybox     cat         cp          date        dd          df
dmesg       grep        kill        ls          mkdir       mknod       mktemp
mount       mv          pidof       ping        ping6       ps          pwd
rm          rmdir       sed         sh          sleep       touch       umount

The cmd/1 function runs whatever you pass it in a shell via sh -c. You can do the same thing with System.cmd/3 and MuonTrap.cmd/3:

iex(4)> System.cmd("echo", ["hello"])
** (ErlangError) Erlang error: :enoent
    (elixir 1.14.1) lib/system.ex:1060: System.cmd("echo", ["hello"], [])
    iex:4: (file)
iex(4)> System.cmd("sh", ["-c", "echo hello"])
{"hello\n", 0}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants