16

I try to use the command telnet in Git Bash, but it shows this error:

bash:telnet: command not found

My operating system is Windows 10. Any idea is appreciated.

Bas Peeters
  • 3,269
  • 4
  • 33
  • 49
Adam Lyu
  • 431
  • 1
  • 5
  • 17

3 Answers3

28

That's because telnet is not provided with git.

In windows, you need to go to control panel, programs, turn windows features on/off and enable the telnet client.

Bas Peeters
  • 3,269
  • 4
  • 33
  • 49
lostbard
  • 5,065
  • 1
  • 15
  • 17
  • 2
    Thanks for the hint. I turn on the service successfully.But when I run it, I got no response from the server. I mean, nothing appears in the command line. Could you help me with that? – Adam Lyu Jul 02 '16 at 01:34
  • what server you trying to connect to? – lostbard Jul 03 '16 at 20:17
  • 6
    after enable telnet service, a new windows command line allows telnet but gitbash does not do anything, no error either. – signonsridhar Feb 16 '18 at 01:51
  • I got response with cmd(Run as administrator) when exec `telnet localhost 2181` ~ black screen appears: write `srvr` – Strauteka Mar 30 '21 at 06:04
8

Enable telnet

Control Panel > Programs > Turn Windows features on or off > Check Telnet Client > Ok

Invoke telnet on git bash

telnet utility need to be invoked with winpty to work on git bash.

Example:

 MINGW64 ~
$ which telnet
/c/WINDOWS/system32/telnet
 MINGW64 ~
$ winpty telnet localhost 2181
    Zookeeper version: 3.4.14-4c25d480e66aadd371de8bd2fd8da255ac140bcf, built on 03/06/2019 16:18 GMT
jumping_monkey
  • 5,941
  • 2
  • 43
  • 58
3

For a programmatic solution, you can use Deployment Image Servicing and Management (DISM)

In windows command prompt, you can use dism to enable features like this:

C:\> dism /online /Enable-Feature /FeatureName:TelnetClient

Or in Powershell, with the DISM Module use Enable-WindowsOptionalFeature like this:

PS> Enable-WindowsOptionalFeature FeatureName:TelnetClient
KyleMit
  • 30,350
  • 66
  • 462
  • 664