Bash "HERE documents " help


Results 1 to 3 of 3

Thread: Bash "HERE documents " help

  1. #1
    Join Date
    May 2005
    Location
    CT
    Posts
    2

    Bash "HERE documents " help

    I'm trying to enter a block of text into an existing configuration file for OpenLDAP so the setup can be fully scripted.

    The text below is what I want to enter into slapd.conf and this all works well and good, however as you probably know this will place the text at the end of the file. What I'd like to know is how can I choose where in an existing file I want to place the text or is this beyond the scope of HERE documents?

    Code:
    cat >> slapd.conf << "EOF"
    access to attrs=userPassword
            by self write
            by anonymous auth
            by dn.base="cn=root,dc=abclott,dc=lott" write
            by group.base="cn=infrastructure,ou=GTECH,ou=groups,dc=abclott,dc=lott" write
            by dn.base="uid=ldapmgr,ou=people,dc=abclott,dc=lott" write
            by * none
    
    access to dn.children="ou=people,dc=abclott,dc=lott"
            by dn.base="cn=root,dc=abclott,dc=lott" write
            by dn.base="cn=bind,dc=abclott,dc=lott" read
            by users read
            by * none
    
    access to dn.children="ou=groups,dc=abclott,dc=lott"
            by dn.base="cn=root,dc=abclott,dc=lott" write
            by dn.base="cn=bind,dc=abclott,dc=lott" read
            by users read
            by * none
    
    access to dn.children="ou=servers,dc=abclott,dc=lott"
            by dn.base="cn=root,dc=abclott,dc=lott" write
            by group.base="cn=infrastructure,ou=GTECH,ou=groups,dc=abclott,dc=lott" write
            by dn.base="cn=bind,dc=abclott,dc=lott" read
            by users read
            by * none
    
    access to dn.subtree="ou=SUDOers,dc=abclott,dc=lott"
            by dn.base="cn=root,dc=abclott,dc=lott" write
            by dn.base="cn=bind,dc=abclott,dc=lott" read
            by users read
            by * none
    
    access to *
            by dn.base="cn=root,dc=abclott,dc=lott" write
            by dn.base="cn=bind,dc=abclott,dc=lott" search
            by * none
    EOF

  2. #2
    Join Date
    Oct 2000
    Location
    Sweden
    Posts
    494
    I don't know really, but since noone has answered I'll give it a shot.
    How about using 'sed', you'll have to find a way to get lots of lines in the expresion - or rather put the result of a command in it.
    sed syntax is
    # sed s/[pattern-to-match]/[pettern-to-replace]/ filename

    As I said, I don't know if it can do what you want but still can't find a reason for why not?
    In pingvino veritas!

  3. #3
    Join Date
    Mar 2012
    Posts
    1

    greetings

    greetings from Switzerland )

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •