dparrish / libcli

Libcli provides a shared library for including a Cisco-like command-line interface into other software. It's a telnet interface which supports command-line editing, history, authentication and callbacks for a user-definable function tree.
https://dparrish.com/link/libcli
GNU Lesser General Public License v2.1
296 stars 147 forks source link

libcli with nc #39

Open mouneshb opened 5 years ago

mouneshb commented 5 years ago

Can we make libcli to work with 'nc - netcat ' ? I tried connecting with nc, it connects but output is not displayed.

RobSanders commented 5 years ago

It can, mostly, but you need to ensure you are using CRLF as the terminators and disable line buffering. From linux this works to talk to the clitest program.

stty_orig=ssty -g ; stty -echo -icanon ; nc localhost 8000; stty $stty_orig

Not sure of the windows equivalent.

RobSanders commented 5 years ago

The above keeps a copy of the existing terminal characteristics, disables local echo and special character processing (and ensures chars are sent one at a time instead of line at a time), then invokes netcat with telnet prompts and CRLF line terminators, and finally restores the terminal settings when done.

pengtianabc commented 1 month ago

use socat: socat -,rawer TCP:127.0.0.1:8000