[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Look, ma no telnet [was: Telnet]



On Mon, Dec 04, 2023 at 09:23:16AM +0100, Nicolas George wrote:
> Charles Curley (12023-12-03):
> > True. None the less, there is at least one perfectly good use for
> > telnet: testing connections to servers.
> 
> Wrong. The telnet client is not entirely transparent, as the telnet
> protocol defines an escape octet to introduce commands.
> 
> If you want to test a network protocol, you should use a really
> transparent client. Traditionally people use netcat (nc), but it handles
> EOF approximatively.
> 
> For that use, I strongly recommend socat.

These days, even bash can do it:

tomas@trotzki:~$ exec 3<>/dev/tcp/localhost/80
tomas@trotzki:~$ echo -ne "GET / HTTP/1.0\r\n\r\n" >&3
tomas@trotzki:~$ cat <&3
HTTP/1.0 200 OK
Content-Type: text/html
ETag: "3243577940"
Last-Modified: Mon, 30 Oct 2017 17:09:28 GMT
Content-Length: 3378
Connection: close
Date: Mon, 04 Dec 2023 18:55:37 GMT
Server: lighttpd/1.4.59

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>


These days, even bash can do it:

  tomas@trotzki:~$ exec 3<>/dev/tcp/localhost/80
  tomas@trotzki:~$ echo -ne "GET / HTTP/1.0\r\n\r\n" >&3
  tomas@trotzki:~$ cat <&3
  HTTP/1.0 200 OK
  Content-Type: text/html
  ETag: "3243577940"
  Last-Modified: Mon, 30 Oct 2017 17:09:28 GMT
  Content-Length: 3378
  Connection: close
  Date: Mon, 04 Dec 2023 18:55:37 GMT
  Server: lighttpd/1.4.59

  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
  <html xmlns="http://www.w3.org/1999/xhtml";>
  <head>
  [... rest elided ...]

;-)

(alas, it can't do TCP server, which is a pity)

Cheers
-- 
t

Attachment: signature.asc
Description: PGP signature


Reply to: