Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #36973
| X-Received | by 10.68.200.168 with SMTP id jt8mr48328pbc.7.1358484357370; Thu, 17 Jan 2013 20:45:57 -0800 (PST) |
|---|---|
| X-Received | by 10.50.203.9 with SMTP id km9mr340905igc.7.1358484357320; Thu, 17 Jan 2013 20:45:57 -0800 (PST) |
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!ld4no7332877pbb.0!news-out.google.com!s9ni24pbb.0!nntp.google.com!ld4no7332874pbb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.python |
| Date | Thu, 17 Jan 2013 20:45:57 -0800 (PST) |
| In-Reply-To | <mailman.609.1358481637.2939.python-list@python.org> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=122.172.199.38; posting-account=uPFZNQoAAAAm9w7z13q1SjWNKNjztdcD |
| NNTP-Posting-Host | 122.172.199.38 |
| References | <mailman.608.1358477462.2939.python-list@python.org> <50f8bd80$0$30003$c3e8da3$5496439d@news.astraweb.com> <mailman.609.1358481637.2939.python-list@python.org> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <189d777e-33c7-4eb6-b301-e477f9122dee@googlegroups.com> (permalink) |
| Subject | Re: [HELP!] a doubt about entering password in python |
| From | Ramchandra Apte <maniandram01@gmail.com> |
| Cc | python-list@python.org |
| Injection-Date | Fri, 18 Jan 2013 04:45:57 +0000 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Xref | csiph.com comp.lang.python:36973 |
Show key headers only | View raw
On Friday, January 18, 2013 9:30:29 AM UTC+5:30, MRAB wrote:
> On 2013-01-18 03:12, Steven D'Aprano wrote:
>
> > On Fri, 18 Jan 2013 10:49:30 +0800, douxin wrote:
>
> >
>
> >> i use Popen to execute "su -c 'fdisk -l'" in sub process,and
>
> >> assigned subprocess.PIPE to stdin,stdout i tried to enter password
>
> >> by doing "stdin.write("password"+"\n")" and i expected i could get
>
> >> the output of "fdisk -l" by doing "stdout.read()"
>
> >> it didn't work.
>
> >>
>
> >> will somebody tell me what is going on with that?
>
> >
>
> > Would you like us to guess what happened? I love guessing games!
>
> >
>
> > My guess is that it output "su: incorrect password", which means you have
>
> > the wrong password. Is that it?
>
> >
>
> > If not, my guess is that it output "fdisk: command not found", in which
>
> > case your system is broken and the fdisk binary is missing or not on the
>
> > PATH. Am I close?
>
> >
>
> > Last guess: you got a Python traceback with an error:
>
> >
>
> > NameError: name 'subprocess' is not defined
>
> >
>
> > You need to import the subprocess first.
>
> >
>
> >
>
> > If none of my guesses are correct, could we have some hints? Perhaps show
>
> > us the actual code you are using, and the actual results, copied and
>
> > pasted exactly.
>
> >
>
> It may, of course, be that for security reasons it won't accept a
>
> password from
>
> whatever happens to be connected to stdin, but instead insists that it's
>
> entered
>
> directly from the keyboard, if you see what I mean.
I think you are correct - su uses some tty magic to stop ECHO and probably doesn't read the password from stdin.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[HELP!] a doubt about entering password in python douxin <wq-doux@cn.fujitsu.com> - 2013-01-18 10:49 +0800
Re: [HELP!] a doubt about entering password in python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-18 03:12 +0000
Re: [HELP!] a doubt about entering password in python MRAB <python@mrabarnett.plus.com> - 2013-01-18 04:00 +0000
Re: [HELP!] a doubt about entering password in python Ramchandra Apte <maniandram01@gmail.com> - 2013-01-17 20:45 -0800
Re: [HELP!] a doubt about entering password in python Chris Angelico <rosuav@gmail.com> - 2013-01-18 17:36 +1100
Re: [HELP!] a doubt about entering password in python Ramchandra Apte <maniandram01@gmail.com> - 2013-01-17 20:45 -0800
csiph-web