unix_telnet(3)
β¨ 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: theNameyou pass around is the one from yourrequirestatement, 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
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms