shell - Python subprocess.Popen usage with a login script fails -


I am attempting to login the script through Python which will be used to login with shell command login -q Will try MyUsername and try multiple passwords I can already generate the required password but when I try to log in using the code below, then login command response Gives me the wrong user name, though I To know that I am writing it correctly, to clarify: I am creating a script to login using shell command login , when I already know the user name but The password below shows what I am doing (again on password).

For the password in the password list: p = popen (["login", "- q", "myUsername"], Stdin = PIPE, stdout = PIPE) #username is myUsername correct , 100% sure print repr (p) stdout_value = p.communicate (password) [0] # print (str (stdout_value)) if repr (stdout_value) .startswith ('login incorrectly \ nlogin:'): print " Error "and: print" good "break

if I type login -q myUsername in the command, I am prompted to write my password While logging using scripts These are incorrect "I am also confused as to how Popen works and how to write on stdout .

Thanks in advance!

(Other questions: Is there an easy way to do this? (Trying to log in using multiple passwords) I am using login because there is no lockdown in it And user data can not be accessed if it is not superuser).

login may be out of process' stdin / stdout Instead, you can read the first cause in your docs:

  import packet output, RC = PaxPreate.run (events like "login-to my you u", events = { "(? I) password:": "password"}, weighitzstats = true)  

Is there an easy way to do this?

read more from hash / etc / passwd, / etc / shadow. Or use a special tool for a weak password such as


Comments