[Gambas-user] 'su -c command' inside Gambas, how do I?

Benoît Minisini gambas at ...1...
Fri Mar 20 12:48:10 CET 2009


> Stefano Palmeri ha scritto:
> > Hi, Benoit. Hi all.
> >
> > I've a little problem here. I can't feed the root password
> > to a "su -c" process invocation. I've attached a little example.
> > In a form there's a textbox. You type the root password,
> > then you press 'Confirm' and you should be able to execute
> > su -c 'cat /etc/sudoers'. But I can't.
> > Any help appreciated. Thanks.
>
> Try using "FOR INPUT OUTPUT" instead of "FOR READ WRITE".
>
> There has been some time ago a discussion on this forum about this
> difference. READ+WRITE is buffered, while INPUT+OUTPUT is not; perhaps,
> what happens is that you write on process stdin, but data never reaches
> it because it waits to fill up its buffer. Using INPUT OUTPUT should not
> try to fill the buffer, but pass the data as soon as it arrives.
> See the docs for (few) more details.
>
> Regards,
> Doriano.
>
>

This is explained in the documentation: for the SHELL and EXEC instructions, 
using INPUT/OUTPUT instead of READ/WRITE runs the process inside a unix 
virtual terminal, which is needed by commands that ask for a password.

Regards,

-- 
Benoît





More information about the User mailing list