Topic: Question about using cmd to run python
Using IDE it can be run successfully:reboot works. but from cmd run the reboot doesn't work but strangely there is no error output.
The script is as below:
import os
import telnetlib
import sys
import string
def telnedo(ip,port,user,password,command):
tn = telnetlib.Telnet(ip,port,20)
tn.read_until(b"username: ")
tn.write(user.encode('utf-8'))
tn.read_until(b"password: ")
tn.write(password.encode('utf-8'))
tn.read_until(b"$ ")
tn.write(command.encode('utf-8'))
ip = '192.168.1.1'
port = 23
user = '123\n'
password = '123\n'
command = 'reboot\n'
telnedo(ip,port,user,password,command)
Thanks for ur help
Last edited by d563229736 (November 14, 2011 04:24)