0

I'm close to loosing my mind here.

I can't get telnet running when launched from a python script. I'm running on a newly installed windows 10.

When I run this script:

import subprocess
cmdline = "telnet 172.19.52.34"
rc = subprocess.call("start cmd /K " + cmdline, shell=True)

I get the dreaded error. The CMD stays open and I can't find the telnet command in C:\Windows\System32.

But when I open a normal CMD, telnet works from C:\Windows\System32. A manual look in the C:\Windows\System32\ shows the telnet executable.

When I test the PATH environment variable inside the python launched CMD, the C:\Windows\System32\ is there.

Any pointers to a solution is MUCH appreciated.

Please bring sanity into my world again. ;-)

Kind regards.

/Bernhard

  • You've looked in the path variable, etc., but can you actually run the command your python code is trying to run, when manually using the command line? ``start cmd /K telnet``? – scnerd Dec 09 '19 at 14:32
  • It's also possible that ``start`` isn't actually a command, but rather a function directly supported by the command line. Can you run just ``subprocess.call("telnet", shell=True)``? – scnerd Dec 09 '19 at 14:34
  • `Start` is a cmd's command. `Start` is used to start programs in unusual ways. Try starting telnet in the NORMAL way. Type `start /?`. –  Dec 09 '19 at 17:33
  • If I run this from Windows Run: "cmd /K telnet 172.19.52.34", it works fine. – BersekerBernhard Dec 09 '19 at 18:03
  • Telnet is just not "visible" from from my script. I never thought that possible. – BersekerBernhard Dec 09 '19 at 18:11
  • This is very puzzling. The same script works on another Windows 10 machine. – BersekerBernhard Dec 09 '19 at 18:17

2 Answers2

0

I found the problem: it was a problem with python 32-bit on a 64-bit windows. After I installed a 64-bit version of python it worked.

  • So what does that mean. A 32 bit program will look in SYSWoW64 for files not System32. You could have specified the 64 bit version by `C:\Windows\sysnative\telnet`. See https://learn.microsoft.com/en-us/windows/win32/winprog64/file-system-redirector _32-bit applications can access the native system directory by substituting %windir%\Sysnative for %windir%\System32_ –  Dec 09 '19 at 18:41
0

Do you have the telnet command enabled in your windows registry?

Paul
  • 36
  • 5