Using ct_telnet to connect to a telnet server

I’m trying to connect to a telnet server that we have. I started off using gen_tcp and while I was able to connect, it wasn’t receiving data like I had hoped so figured I’d give erlangs ct_telnet a try.

I’m new to Elixir so trying to decipher the Erlang docs and figuring out how to translate that into Elixir is a bit of a challenge.

I’m just trying to do a simple open and close right now but I’m getting an error and hoped someone could point me in the right direction.

defmodule UvTel do
  def hello do
    {:ok, handle} ="")

    :ok = :ct_telnet.close(handle)

** (ArgumentError) argument error
    (stdlib), [{{:ct_conf, :"$1", :_, :_, :_, "", :_}, [], [:"$1"]}])
    ct_config.erl:576: :ct_config.get_key_from_name/1
    (uv_tel) lib/uv_tel.ex:16: UvTel.hello/0

Thank you.

Change to:

{:ok, handle} ='')

Most erlang things use charlists instead of binaries. :slight_smile:

Nope, will not do it.

ct_telnet is part of the ct testing framework and not a telnet client library.

Aside of that, takes its first argument of type ct.target_name(), which again is just an alias to atom(), so if at all he has to use"").

1 Like

I tried that as well, but still get this error. I feel like I’m missing something that correlates a key or name to an ip address and some settings. Not sure.

** (ArgumentError) argument error
    (stdlib), [{{:ct_conf, :"$1", :_, :_, :_, '', :_}, [], [:"$1"]}])
    ct_config.erl:576: :ct_config.get_key_from_name/1
    (uv_tel) lib/uv_tel.ex:3: UvTel.hello/0

Do I need to add something in mix.exs to use that framework?

Do you want to use it to test your library?

Again, ct is not meant to be used as a runtime dependency, it is a testing framework like ExUnit.

1 Like

Well, I’m really just trying a proof of concept to see what can be done. We have a database server (it’s similar to Pick Operating System Database - comes from the 60’s) that we connect to over telnet. I’m just trying to automate some of those tasks and wanted to see what I could accomplish with Elixir. Is there something else I can use? gen_tcp allowed me to connect but I was receiving data in strange ways. I thought maybe ct_telnet was a better choice, but maybe not.

I do not know that database, nor have I worked with it, but for a rough prototype you should be able to use it. But you shouldn’t go with it into production.

Telnet is a character-based protocol, but ct_telnet does only allow to receive proper lines, not single chars. So if you can actually use this depends on your target host.

But perhaps you can build a proper telnet client on top of gen_tcp and publish it on

Aside of that, telnet has only been formalized in 1973, so your target host may speak a dialect that is not widely supported nowadays.

1 Like

Thank you. I’ll look at the telnet standards. Trust me, You don’t want to know that database.

1 Like