Question

I have made a script which is used to run an APP on MACOS It basically controls camera using and IP address

My problem is it required a password

I am using the http://docs.python.org/2/library/telnetlib.html#telnetlib.Telnet example from here but it is not working I do not want it to prompt the user for the password, I simply want to HardCode it everytime the app runs.

if ip:
        self.conn = telnetlib.Telnet(ip, 24)
        self.consume_telnet()
    else:
        self.conn = None


def telnet_send(self, s):
    passCode = '********'                            
    password = getpass.getpass()
    if self.conn:
        self.conn.write(s + '\r\n')
        if password:
            self.conn.read_until('Password: ')
            self.conn.write(password.strip() + '\n')

    else:
        print s

No correct solution

OTHER TIPS

Password is prompted by getpass.getpass() call. This method always asks user for the password. Check this doc page: http://docs.python.org/2/library/getpass.html

I am assuming you are doing initialization outside telnet_send method. Simply setup your password inside this initialization code --- something like self.password = getpass.getpass() and then use this password elsewhere.

self.password = getpass.getpass()

def telnet_send(self, s):
   passCode = '********'                            
   if self.conn:
      self.conn.write(s + '\r\n')
      if self.password:
          self.conn.read_until('Password: ')
          self.conn.write(self.password.strip() + '\n')
   else:
       print s
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top