ssh - How to detect expired password using Python Fabric? -


using following code, i'm unable fabric detect expired password prompt @ login. session doesn't timeout, , abort_on_prompts parameter doesn't appear triggering. how can configure fabric detect state?

from fabric.api import env, run, execute fabric import network fabric.context_managers import settings  def host_type():     settings(abort_on_prompts=true):         print ("using abort mode %(abort_on_prompts)s" % env)         result = run('uname -s') return result  if __name__ == '__main__':     print ("fabric v%(version)s" % env)     env.user = 'myuser'     env.password = 'user67user'     env.hosts = ['10.254.254.143']     host_types = execute(host_type) 

executing script results in hung script, depicted below:

      fabric v1.11.1.post1     [10.254.254.143] executing task 'host_type'     using abort mode true     [10.254.254.143] run: uname -s     [10.254.254.143] out: warning: password has expired.     [10.254.254.143] out: must change password , login again!     [10.254.254.143] out: changing password myuser.     [10.254.254.143] out: (current) unix password:   

fabric include way answer prompts questions.

you can use prompts dictionary on with settings. in dictionary every key question in standard output want answer, , value answer.

so in example:

from fabric.api import env, run, execute fabric import network fabric.context_managers import settings  def host_type():     settings(prompts={"(current) unix password": "new_password"}):         result = run('uname -s') return result  if __name__ == '__main__':     print ("fabric v%(version)s" % env)     env.user = 'myuser'     env.password = 'user67user'     env.hosts = ['10.254.254.143']     host_types = execute(host_type)