1

I am trying to use telnetlib to send commands to a device. The following is the command I am using:

tn = telnetlib.Telnet("10.62.48.96")

tn.write('c:/Test/Minte/TE.exe c:/data/test/bin/Test.dll >> c:/test/test.log \r\n')

print "Read",tn.read_until('cmd.exe ', 90)

The response I am getting is printing only until Test.dll and its nothing after that. I am doubting if write function can send commands with more than one space.

I know the command is not getting executed because test.log is not getting generated at the destination path.

Response:

C:\windows\system32>c:/Test/Minte/TE.exe c:/data/test/bin/Test.dll←[4;71H
tshepang
  • 12,111
  • 21
  • 91
  • 136
Shesh
  • 11
  • 3
  • This probably has more to do with how much that device can buffer at once. Open up command prompt open the telnet session and see how much it will let you send. – flakes Apr 10 '14 at 19:09
  • on telnet I can send more than that... I have been using this manually from telnet all the time and it works absolutely fine. – Shesh Apr 10 '14 at 19:27
  • I'm experiencing a similar problem. Commands that are longer than 34 characters do execute, but when you read the output with the expect() commands, the characters at position >34 will be read too! – Erikw Sep 12 '14 at 11:02

2 Answers2

0

perhaps it has to do with escaped characters >> .

http://ss64.com/nt/syntax-esc.html

tn.write('"c:/Test/Minte/TE.exe c:/data/test/bin/Test.dll" >> c:/test/test.log \r\n')

or something like

tn.write('c:/Test/Minte/TE.exe "c:/data/test/bin/Test.dll >> c:/test/test.log" \r\n')
flakes
  • 21,558
  • 8
  • 41
  • 88
  • Looks like there is limit to the length of command that write() function can take. I gave a command that is 50chars and less and it worked. Same command I change the file name to be longer and did not work. – Shesh Apr 10 '14 at 21:44
0

Yes, it has a limit to 50 characters only. Yry doing tn.read_very_eager().

tshepang
  • 12,111
  • 21
  • 91
  • 136
Shubham srivastava
  • 227
  • 1
  • 4
  • 12