non-interactive scripting

Darryl Moore darryl-90a536wCiRb3fQ9qLvQP4Q at
Mon Sep 28 22:24:44 UTC 2009

Terrence Enger wrote:
> On Mon, 2009-09-28 at 17:36 -0400, Darryl Moore wrote:
>> Hey all,
>> I did some googling to find out how to write non-interactive script for
>> creating GPG keys. I found it and now I have the following in my script
>> cat <<-EOF | gpg --batch --quick-random --no-tty --gen-key
>> %echo Generating a standard key
>> Key-Type: DSA
>> Key-Length: 1024
>> Subkey-Type: ELG-E
>> Subkey-Length: 1024
>> Name-Real:
>> Name-Comment: $COMPANY
>> Name-Email: $CONTACT_EMAIL
>> Expire-Date: 0
>> Passphrase: $PASSPHRASE
>> # Do a commit here, so that we can later print "done" :-)
>> %commit
>> %echo done
>> EOF
>> This all works, but there are a few things I can't figure out (and Mr.
>> Google doesn't seem to be much help either. ).
>> 1) what is with the minus sign between the double-less-than signs and
>> the EOF? The code I found had it in, I'd expect it not to work with it
>> there, but it does. Does it do anything?
> Indeed it does:  with the dash before the EOF string, bash strips
> leading tab characters from each line of the "here" document.  This lets
> you push the data out to the right so that it does not hide the
> indentation which shows the structure of your bash code.  I find this
> feature really useful.

Fabulous. Thanks. Now knowing that, I've been able to make some better
focused google searches and come up with more examples.
I'll file this tidbit away for future use.


The Toronto Linux Users Group.      Meetings:
TLUG requests: Linux topics, No HTML, wrap text below 80 columns

More information about the Legacy mailing list