Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #36969

[HELP!] a doubt about entering password in python

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin.stu.neva.ru!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <wq-doux@cn.fujitsu.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.006
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'output': 0.04; 'subject:password': 0.05; 'that?': 0.05; 'python': 0.09; 'sub': 0.09; 'timeout': 0.09; 'subject:python': 0.11; 'all?': 0.16; 'skip:" 30': 0.20; 'all:': 0.22; 'programming': 0.23; 'work.': 0.23; 'somebody': 0.23; 'command': 0.24; 'script': 0.24; 'tried': 0.25; 'header:User-Agent:1': 0.26; 'done.': 0.27; 'probably': 0.29; 'could': 0.32; 'certain': 0.33; 'problem': 0.33; 'to:addr :python-list': 0.33; 'needed': 0.35; 'doing': 0.35; 'expected': 0.35; 'wanted': 0.36; "didn't": 0.36; "i'll": 0.36; 'execute': 0.37; 'subject:[': 0.37; 'some': 0.38; 'received:10': 0.38; 'to:addr:python.org': 0.39; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'real': 0.61; 'received:unknown': 0.63; 'doubts': 0.84
X-IronPort-AV E=Sophos;i="4.84,488,1355068800"; d="scan'208,217";a="6609186"
Date Fri, 18 Jan 2013 10:49:30 +0800
From douxin <wq-doux@cn.fujitsu.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110930 Thunderbird/7.0.1
MIME-Version 1.0
To python-list@python.org
Subject [HELP!] a doubt about entering password in python
X-MIMETrack Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/01/18 10:49:00, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/01/18 10:49:00, Serialize complete at 2013/01/18 10:49:00
Content-Type multipart/alternative; boundary="------------080000090705010506060901"
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.608.1358477462.2939.python-list@python.org> (permalink)
Lines 72
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1358477462 news.xs4all.nl 6899 [2001:888:2000:d::a6]:34270
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:36969

Show key headers only | View raw


[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


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