Re: Python & Linux, some questions (2)

From: Simon Burton (simonb_at_NOTTHISBIT.webone.com.au)
Date: 03/16/04


Date: Tue, 16 Mar 2004 22:11:30 +1100

On Mon, 15 Mar 2004 20:45:53 -0700, Hamilcar Barca wrote:

> In article <c353om$23bqmc$1@ID-99001.news.uni-berlin.de> (Mon, 15 Mar 2004
> 21:28:47 +0100), Luca T. wrote:
>
>> r,w,e = popen2.popen3('su -c ls')
>>
>> So it seems that "su" refuses to work if it is run like this.
>
> su needs the user's password and it insists on reading it from a tty
> because it can control echoing.

Maybe pexpect can help you here. It works great on linux.

Simon.



Relevant Pages

  • Re: Python & Linux, some questions (2)
    ... su needs the user's password and it insists on reading it from a tty ... because it can control echoing. ... Create a copy of ls and make it suid root. ...
    (comp.lang.python)
  • os.fork and pty.fork
    ... running python without a tty. ... I use pexpect to connect to ssh and run ... command in the child with os.exec. ...
    (comp.lang.python)
  • Re: How to synchronously capture pipe output?
    ... Make stdout a tty or something reasonably close to it. ... Use the sucksystem call on the reading end of the pipe. ... Expressed in this posting are my opinions. ... to opinions held by my employer, Sun Microsystems. ...
    (comp.unix.programmer)
  • Re: read stdout/stderr without blocking
    ... When reading from a pty like pexpect does, your read will not block until the stdio block buffer is filled. ...
    (comp.lang.python)
  • Re: How to execute a linux command by python?
    ... Fredrik Lundh wrote: ... After reading the matl. ... you can try pexpect. ...
    (comp.lang.python)