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: 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 This is a multi-part message in MIME format. --------------080000090705010506060901 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=ISO-8859-1; format=flowed 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 --------------080000090705010506060901 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=ISO-8859-1 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
--------------080000090705010506060901--