From owner-freebsd-questions@FreeBSD.ORG Thu Jul 28 09:10:40 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A352016A420 for ; Thu, 28 Jul 2005 09:10:40 +0000 (GMT) (envelope-from martin@orbweavers.co.uk) Received: from mail.orbweavers.co.uk (213-152-38-100.dsl.eclipse.net.uk [213.152.38.100]) by mx1.FreeBSD.org (Postfix) with ESMTP id 827BC43D45 for ; Thu, 28 Jul 2005 09:10:38 +0000 (GMT) (envelope-from martin@orbweavers.co.uk) Received: from www.orbweavers.co.uk (localhost.orbweavers.co.uk [127.0.0.1]) by mail.orbweavers.co.uk (Postfix) with ESMTP id B27D2B2B88; Thu, 28 Jul 2005 10:10:37 +0100 (BST) Received: from 217.37.3.201 (SquirrelMail authenticated user martin) by www.orbweavers.co.uk with HTTP; Thu, 28 Jul 2005 10:10:37 +0100 (BST) Message-ID: <1136.217.37.3.201.1122541837.squirrel@www.orbweavers.co.uk> In-Reply-To: References: <1559.192.168.0.10.1122502486.squirrel@192.168.0.5> Date: Thu, 28 Jul 2005 10:10:37 +0100 (BST) From: martin@orbweavers.co.uk To: "Garance A Drosihn" User-Agent: SquirrelMail/1.4.4 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal Cc: freebsd-questions@freebsd.org Subject: Re: Shell script frustration X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jul 2005 09:10:40 -0000 > At 11:14 PM +0100 7/27/05, martin@orbweavers.co.uk wrote: >> >>echo ldapdelete -W -D $binddn \"cn=$1, $group_base\" >>ldapdelete -W -D $binddn \"cn=$1, $group_base\" > > >>when run ('./rmgroup users') it outputs - >> >>ldapdelete -W -D "cn=Manager,dc=orbweavers,dc=co,dc=uk" "cn=users, >>ou=groups,dc=orbweavers,dc=co,dc=uk" >>Enter LDAP Password: >>ldap_bind: Invalid DN syntax (34) >> additional info: invalid DN >> >>However, if I copy and paste the echod statement (the first line >>of the output) straight to the shell, it run fine. > > What I do in this cases is create a script called "list_args.sh": > > #!/bin/sh > printf "\nlist_args.sh at `date +%H:%M:%S` with \$# = $#\n" > # Process all parameters. > N=0 > while test $# != 0 ; do > N=$(($N+1)) > printf " \$$N = [%3d] '$1'\n" ${#1} > shift > done > > Then in your script, replace the ldapdelete command with > list_args.sh. That way you'll see *exactly* what ldapdelete > is seeing for parameters, and that might help. I tried that one, with an echo $* - though I assume the printf prints it out 'more precise'? I've come up with a work around - in my slapd.conf I have quotes around the rootdn, if I take them off it works fine (I did try it without the quotes around the variable, but that didn't work either, much confusion) I'd love to know what was causing the problem, but enough time is spend on it. I will update the script to strip off quotes when found, which should sort it out. I now have the LDAP tools I discussed earlier written. Very rough and ready, but they do the job I want, so they are 'complete' in that respect! We have: adduser - adds a user, and a group if it does not already exist rmuser - removes a user rmgroup - removes a group users - prints a list of users found, or details if a username is passed groups - prints a list of groups found, or details if a groupname is passed passwd - change a user password They are certainly not ready for an end user, but if anyone wants to make use of them or polish them up a bit, let me know and I will send them to you. I will put them up on my site at some point over the week. Cheers, Martin