1

Sometimes telnet is used for testing non telnet servers such as HTTP or SMTP servers where the TELNET protocol usually stays out of the way. However, I think I have run into a case where it is in the way while debugging a TCP server. I ran

telnet localhost < data_file

And the data the server receives is different than what is in the file.

Is there either an option to telnet or a whole nother command that I can use?

If it has to be installed separately, then I don't want it. I will just do without.

700 Software
  • 2,233
  • 10
  • 49
  • 77

4 Answers4

7

Well, actually it's called netcat and is Not a built-in for Solaris. But you have another option if you use bash or zsh (or may be something else):

man bash:

Bash handles several filenames specially when they are  used
in redirections, as described in the following table:
  …
     /dev/tcp/host/port
          If host is a valid hostname or  Internet  address,
          and  port  is  an  integer  port number or service
          name, bash attempts to open a  TCP  connection  to
          the corresponding socket.
poige
  • 9,448
  • 2
  • 25
  • 52
  • 1
    That is nice to know about `bash` and `/dev/tcp`. I don't see the capability of a two way connection though, but I expect this will be helpful down the road,, and for the more needy cases, I will just write my own script. – 700 Software Jul 06 '11 at 14:54
  • Excelent!! Rare knowlege – xoid May 12 '20 at 12:24
3

I guess netcat? There's a package here. But it isn't provided by Sun default. Do you have something against packages?

Michael Lowman
  • 3,604
  • 20
  • 36
  • Yes, it is temporary until a new plan is in place for server configuration management. Right now, everything needs to stay put. – 700 Software Jul 06 '11 at 14:57
  • IMHO, a well-documented list of installed packages will work just as well for management purposes. And I would say that the benefit of using the extensive GNU tools that aren't available in a base install on Solaris outweighs the benefits of using a completely base system. But that's definitely your choice to make :) – Michael Lowman Jul 06 '11 at 14:59
3

As poige already said: You can use the /dev/tcp// device. Here is an example:

bash-3.2$ cat </dev/null >/dev/tcp/1.2.3.4/22; echo $?
0
bash-3.2$ cat </dev/null >/dev/tcp/1.2.3.4/1522; echo $?
bash: connect: Connection timed out
bash: /dev/tcp/1.2.3.4/1522: Connection timed out
1

You probably write a small bash script for this. The "timed out" message appears after TCP timeout which ich mostly set to 4 minutes. That's quite long...

0

Maybe tcpdump? But since it is obviously not important...

Sven
  • 98,649
  • 14
  • 180
  • 226