unix_telnet(3)

πŸ“¦
version 29.0.6 Β· 3 versions
, in ubuntu stonking

✨ unix_telnet ✨

okay so bestie, we're looking at a page from the Erlang Module Definition manual β€” it's the unix_telnet module, and it's giving "callback module for ct_telnet, but make it UNIX". πŸ’…


πŸŽ€ NAME πŸŽ€

unix_telnet β€” the callbacks module for ct_telnet, here to hook you up with a Telnet server on a UNIX host. no cap, that's literally its whole job. πŸ¦‹


🌸 DESCRIPTION 🌸

okay so first things first, it requires this entry in the config file, like required-required, not a suggestion:

{unix,[{telnet,HostNameOrIpAddress},
       {port,PortNum},                 % optional
       {username,UserName},
       {password,Password},
       {keep_alive,Bool}]}.            % optional

so to actually talk through Telnet to the host that HostNameOrIpAddress points at, you use the interface functions over in ct_telnet β€” for example open(Name) and cmd(Name,Cmd). those are your besties for this. 🫢

and <italic>Name</italic> is the name you gave the Unix host in your require statement, like:

suite() -> [{require,Name,{unix,[telnet]}}].

or, alternatively:

ct:require(Name,{unix,[telnet]}).

either one, whichever slays for your setup. ✨

now, the "keep alive" activity β€” and ICYMI, that means Common Test sends NOP to the server every 10 seconds whenever the connection is just sitting there idle β€” you can turn that on or off for one particular connection, exactly as described here. πŸ’– you can also disable it for all connections using telnet_settings (go peek at ct_telnet for that one, iykyk).

the {port,PortNum} tuple? optional. skip it and the default Telnet port 23 is what you get. and the keep_alive tuple is optional too β€” its value defaults to true, aka enabled. periodt. πŸ‘‘

πŸ‘€ See Also

ct, ct_telnet


πŸ”₯ FUNCTIONS πŸ”₯

πŸ’« connect

connect(ConnName, Ip, Port, Timeout, KeepAlive, TCPNoDelay, Extra) ->
                 {ok, Handle} | {error, Reason}
                 when
                     ConnName :: ct:target_name(),
                     Ip :: inet:socket_address() | inet:hostname(),
                     Port :: inet:port_number(),
                     Timeout :: timeout(),
                     KeepAlive :: boolean(),
                     TCPNoDelay :: boolean(),
                     Extra :: {Username, Password} | KeyOrName,
                     Username :: iodata(),
                     Password :: iodata(),
                     KeyOrName :: ct:key_or_name(),
                     Handle :: ct_telnet:handle(),
                     Reason :: term().
  • callback for ct_telnet.erl, bestie β€” it's the one doing the reaching out. 🌈
  • what it does: sets up the Telnet connection to a Unix host. that's the whole vibe. ✨

πŸ’« get_prompt_regexp

get_prompt_regexp() -> Pattern
                           when Pattern :: ct_telnet:prompt_regexp().
  • also a callback for ct_telnet.erl. 🫢
  • returns a suitable regexp string that matches the common prompts users have on Unix hosts. iconic behaviour, honestly. πŸ’–

lowkey important reminder: the Name you pass around is the one from your require statement, and <bold>the "keep alive" NOP-every-10-seconds-when-idle thing</bold> is on by default unless you say otherwise. don't be out here confused when your connection starts pinging. πŸ’€

okay and that's a wrap, my love πŸ’œ β€” this whole page came from Ericsson AB, <rainbow>common_test 1.31.1</rainbow>, and it's the unix_telnet(3) entry. go connect to something, you got this. πŸŽ€πŸ¦‹βœ¨

πŸ“¦ where this page comes from