SAFplus Runtime Director API  3.0.5
pxsshfix.pxssh Class Reference

This is exactly like the pxssh class in the pexpect module except that the -o UserKnownHostsFile=/dev/null flag is added so that the the "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!" error cannot occur during ssh. More...

Inherits pxssh.

Public Member Functions

def __init__
 
def read_nonblocking
 This reads at most size characters from the child application. More...
 
def synch_original_prompt
 This attempts to find the prompt. More...
 
def login
 This logs the user into the given server. More...
 

Public Attributes

 flag_eof
 
 before
 
 after
 
 buffer
 

Detailed Description

This is exactly like the pxssh class in the pexpect module except that the -o UserKnownHostsFile=/dev/null flag is added so that the the "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!" error cannot occur during ssh.

flush fd

Constructor & Destructor Documentation

def pxsshfix.pxssh.__init__ (   self,
  timeout = 30,
  maxread = 2000,
  searchwindowsize = None,
  logfile = None,
  cwd = None,
  env = None 
)

Member Function Documentation

def pxsshfix.pxssh.login (   self,
  server,
  username,
  password = '',
  terminal_type = 'ansi',
  original_prompt = r"[#$]",
  login_timeout = 10,
  port = None,
  auto_prompt_reset = True,
  forwardX = True 
)

This logs the user into the given server.

It uses the 'original_prompt' to try to find the prompt right after login. When it finds the prompt it immediately tries to reset the prompt to something more easily matched. The default 'original_prompt' is very optimistic and is easily fooled. It's more reliable to try to match the original prompt as exactly as possible to prevent false matches by server strings such as the "Message Of The Day". On many systems you can disable the MOTD on the remote server by creating a zero-length file called "~/.hushlogin" on the remote server. If a prompt cannot be found then this will not necessarily cause the login to fail. In the case of a timeout when looking for the prompt we assume that the original prompt was so weird that we could not match it, so we use a few tricks to guess when we have reached the prompt. Then we hope for the best and blindly try to reset the prompt to something more unique. If that fails then login() raises an ExceptionPxssh exception.

In some situations it is not possible or desirable to reset the original prompt. In this case, set 'auto_prompt_reset' to False to inhibit setting the prompt to the UNIQUE_PROMPT. Remember that pxssh uses a unique prompt in the prompt() method. If the original prompt is not reset then this will disable the prompt() method unless you manually set the PROMPT attribute.

def pxsshfix.pxssh.read_nonblocking (   self,
  size = 1,
  timeout = -1 
)

This reads at most size characters from the child application.

It includes a timeout. If the read does not complete within the timeout period then a TIMEOUT exception is raised. If the end of file is read then an EOF exception will be raised. If a log file was set using setlog() then all data will also be written to the log file.

If timeout is None then the read may block indefinitely. If timeout is -1 then the self.timeout value is used. If timeout is 0 then the child is polled and if there was no data immediately ready then this will raise a TIMEOUT exception.

The timeout refers only to the amount of time to read at least one character. This is not effected by the 'size' parameter, so if you call read_nonblocking(size=100, timeout=30) and only one character is available right away then one character will be returned immediately. It will not wait for 30 seconds for another 99 characters to come in.

This is a wrapper around os.read(). It uses select.select() to implement the timeout.

def pxsshfix.pxssh.synch_original_prompt (   self)

This attempts to find the prompt.

Basically, press enter and record the response; press enter again and record the response; if the two responses are similar then assume we are at the original prompt.

Member Data Documentation

pxsshfix.pxssh.after
pxsshfix.pxssh.before
pxsshfix.pxssh.buffer
pxsshfix.pxssh.flag_eof