Giter VIP home page Giter VIP logo

Comments (3)

joserpintuitivo avatar joserpintuitivo commented on June 24, 2024

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

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

from muontrap.

joserpintuitivo avatar joserpintuitivo commented on June 24, 2024
iex(1)> System.cmd("echo", ["hello"])
** (ErlangError) Erlang error: :enoent
    (elixir 1.12.3) lib/system.ex:1041: System.cmd("echo", ["hello"], [])

from muontrap.

fhunleth avatar fhunleth commented on June 24, 2024

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}

from muontrap.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.