non-interactive scripting

Brandon Sandrowicz bsandrow-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Tue Sep 29 15:51:36 UTC 2009


On Mon, Sep 28, 2009 at 2:36 PM, Darryl Moore <darryl-90a536wCiRb3fQ9qLvQP4Q at public.gmane.org> wrote:
> 3) Why cannot I not accomplish the same thing by not using --batch and
> simply piping the answers to prompted questions in the same manor as
> above? I've tried. It doesn't work. I still get the prompts as if there
> never was any stdin redirect.

gpg is probably like ssh in that it read/writes directly to the
terminal device rather than stdin/stdout.  That's why you need to use
something like expect or pexpect (python version) to script running
ssh (with a password prompt, that is) because it emulates a terminal.
Basically any program that looks like it's just doing stdin/stdout but
does things like masking your password when you type it in (or just
not showing any characters at all) is hooked directly into the
terminal device. I'm sure others here are more versed in the specifics
of TTYs and PseudoTTYs.  Reading/writing directly to the terminal
device is supposed to be more secure though other than password
masking I'm not sure why.

I remember there being a brief blurb about this in pexpect (which is
where I first picked up this knowledge, IIRC).

When you use the --batch switch you're telling it that you're going to
be using redirection so it needs to use stdin/stdout.
-- 
Brandon
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list