Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #36969
| Date | 2013-01-18 10:49 +0800 |
|---|---|
| From | douxin <wq-doux@cn.fujitsu.com> |
| Subject | [HELP!] a doubt about entering password in python |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.608.1358477462.2939.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
Hi all:
i have some doubts in doing python programming
i wanted to execute a command "su -c 'fdisk -l'",and it needed a
password
so i wanted to write a python script to get this done.
i knew 'pexpect' would work fine,but i had to set a certain timeout
to take care of the real delay time which i probably didn't know
i tried to use 'subprocess' to do this,however,it did not work
well,and came the problem
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?
i'll appreciate i can learn from you
Dou
Back to comp.lang.python | Previous | Next — 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