Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

shell script containing ldapmodify - hardcoding commands

I'm trying to run an ldapmodify command in a shell script, but I don't want to specify an external file containing commands (-f flag). This would just be for convenience - the commands in the external file would be dynamic, so it would be nice to avoid writing a new file every time the shell script ran ldapmodify. I would want the script to essentially enter the following into the command line:

prompt/> ldapmodify -v -H LDAP://111.111.111.11 -D "CN=binding_user,DC=example,DC=com" -x -w password
> dn: CN=group_name, OU=Groups, DC=example, DC=com
> changetype: modify
> add: member
> member: CN=Smith\, John, OU=Users, DC=example, DC=com
> (user presses Ctrl-D)

Anyone know of how to do this?

like image 700
SheerSt Avatar asked Jul 24 '13 15:07

SheerSt


1 Answers

Use a "here" document:

ldapmodify .. <<!
dn: dc=example,dc=com
changetype: modify
replace: description
 -
add: description
description: The new description
!

For example.

like image 133
Terry Gardner Avatar answered Sep 27 '22 22:09

Terry Gardner