Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to send some text to a port on my machine using telnet in the Mac OS X Terminal.

I start telnet using:

telnet localhost 8080

Then I type some text. Is that text send automatically or do I have to do something to send the text?

share|improve this question
What is listening on port 8080? It is an address commonly used for web servers when the usual HTTP port 80 is unavailable. If it is a web server, you need to send a complete HTTP request, finished by two newlines (return characters, really). Normally, as explained by Laas below, a newline will trigger the sending of a line. – Harald Hanche-Olsen May 20 '11 at 13:50

Here's a simple Python server:

#!/usr/bin/env python

import socket

TCP_IP = ''
TCP_PORT = 5005
BUFFER_SIZE = 10  # Normally 1024, but we want fast response

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((TCP_IP, TCP_PORT))

conn, addr = s.accept()
print 'Connection address:', addr
while 1:
    data = conn.recv(BUFFER_SIZE)
    if not data: break
    print "received data:", data
    conn.send(data)  # echo


Save it as, and run it python

Then try to connect using the terminal

telnet 5005

Then just type anything and press return

The server print the data in the console and send it back to you.

That way, you'll know what you have to do to send data via telnet.

share|improve this answer

The answer depends on what the remote end supports:

  1. Newer Line Mode where character processing is done locally while the remote only sends and receives control packets during typing and receives whole line when entering some end-of-line char (e.g hitting ENTER).
  2. Character-at-a-time where each char is transmitted as it is typed.
  3. Old line-at-a-time - fully completed lines are transmitted.

What the remote end does with the received input, depends on the remote end. Most server processes (HTTP, SMTP, POP, IMAP) tend to wait for end-of-line (EOL, newline) char before processing input. Some others may wait for end-of-file (EOF, ^D) before starting to process the input.

share|improve this answer

Try using send command after you've opened connection to the destination host.

send "some text"

For more information about send see man telnet

share|improve this answer
I tried, but I just get a new line when I press enter after it. – Jonas May 20 '11 at 12:12
The send command is for sending special character sequences to remote machines, not random text. See the man page:… – Ian C. Sep 17 '14 at 16:58
telnet> send "some text"
Unknown send argument 'some text'
'send ?' for help.

welcome to mac world, where nothing works... I already check the source code of the telnet for mac, and there is no function to send a text...

source code:

share|improve this answer
Could you highlight were in the attachment you found the info. – Buscar웃 Sep 17 '14 at 16:26
This answer is completely wrong. Of course you can send text with the telnet application. It functions the same as telnet on any BSD system. The send command is for sending special character sequences to remote machines, not random text. See the man page:… – Ian C. Sep 17 '14 at 16:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.