How To Send IO To An Erlang Port?

Onorio Catenacci

I'm trying to hack together a little CLI for Windows and, inspired by James Smith's Elixirconf talk, I was trying to use a Port to drive the interaction. So this is what I tried:

Interactive Elixir (0.14.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> p = Port.open({:spawn,"clip"},[:stderr_to_stdout, :in, :exit_status])
#Port<0.1048>
iex(2)> send(p,"This is a test")
"This is a test"

The "clip" utility simply takes whatever is piped into it and puts it on Windows clipboard. If you were to call it from the command line, you'd call it like this

dir | clip

So as far as I can tell nothing's getting to the clipboard via my test. I just wanted to ask if I'm sending the input to the stdio in the right fashion--I mean do I want to use send for that?

Interestingly if I do this:

p = Port.open({:spawn, "clip"}, [:stderr_to_stdout, :exit_status]) #Note no :in parameter
send(p,"This is a test")

I get this:

** (EXIT from #PID<0.45.0>) :badsig

I can't tell if the IO is actually getting sent to clip or not but I just wanted to confirm I'm doing the command correctly.

Windows 7 SP1

Alexei Sholik

You don't need :in and you need to pass to the port {:stream, :binary} to be able to send to it bare strings.

Also try using port_command instead of sending to the port pid. http://www.erlang.org/doc/man/erlang.html#port_command-2

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to get Ephemeral port for UDP in Erlang?

From Dev

How to send messages across two Erlang Nodes

From Dev

How to send message to receive in YAWS/Erlang

From Dev

How to send message to receive in YAWS/Erlang

From Dev

How to send command to serial port (JAVA + RXTX)

From Dev

How to send command to serial port (JAVA + RXTX)

From Dev

How to send data through parallel port in Python?

From Dev

Port 25 not open, how send email?

From Dev

How to include a variable in io:get_line (Erlang)

From Dev

Erlang badarith on IO input

From Dev

How to send binary data with socket.io?

From Dev

Socket.io how to send a message to anyone?

From Dev

Erlang: port to Python instance not responding

From Dev

How do you run express and socket.io on the same port

From Dev

How to configure Socket.io to run on same port on https?

From Dev

How to start node express, binaryserver and socket.io on same port?

From Dev

Vue - How to use a different socket.io port in tests?

From Dev

io:format with multiple variables - Erlang

From Dev

io:format with multiple variables - Erlang

From Dev

Efficiency of IO lists in elixir/erlang

From Dev

How to send UDP packet to specific UDP dst port in scapy?

From Dev

how can server send its multicast address and port number in android?

From Dev

How to split given text into 3 variables in bash and send to host at port?

From Dev

How to send data to a serial port and see any answer?

From Dev

How does the server find out what client port to send to?

From Dev

How to send data from the same port after listening in c++?

From Dev

How handle a non-resumable ordered delivery send port

From Dev

How to send data through TCP/IP/UDP to serial port?

From Dev

How send one bit(no byte) through ethernet port

Related Related

  1. 1

    How to get Ephemeral port for UDP in Erlang?

  2. 2

    How to send messages across two Erlang Nodes

  3. 3

    How to send message to receive in YAWS/Erlang

  4. 4

    How to send message to receive in YAWS/Erlang

  5. 5

    How to send command to serial port (JAVA + RXTX)

  6. 6

    How to send command to serial port (JAVA + RXTX)

  7. 7

    How to send data through parallel port in Python?

  8. 8

    Port 25 not open, how send email?

  9. 9

    How to include a variable in io:get_line (Erlang)

  10. 10

    Erlang badarith on IO input

  11. 11

    How to send binary data with socket.io?

  12. 12

    Socket.io how to send a message to anyone?

  13. 13

    Erlang: port to Python instance not responding

  14. 14

    How do you run express and socket.io on the same port

  15. 15

    How to configure Socket.io to run on same port on https?

  16. 16

    How to start node express, binaryserver and socket.io on same port?

  17. 17

    Vue - How to use a different socket.io port in tests?

  18. 18

    io:format with multiple variables - Erlang

  19. 19

    io:format with multiple variables - Erlang

  20. 20

    Efficiency of IO lists in elixir/erlang

  21. 21

    How to send UDP packet to specific UDP dst port in scapy?

  22. 22

    how can server send its multicast address and port number in android?

  23. 23

    How to split given text into 3 variables in bash and send to host at port?

  24. 24

    How to send data to a serial port and see any answer?

  25. 25

    How does the server find out what client port to send to?

  26. 26

    How to send data from the same port after listening in c++?

  27. 27

    How handle a non-resumable ordered delivery send port

  28. 28

    How to send data through TCP/IP/UDP to serial port?

  29. 29

    How send one bit(no byte) through ethernet port

HotTag

Archive