From owner-freebsd-questions@FreeBSD.ORG Thu Jul 28 16:40:34 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 8543C16A41F for ; Thu, 28 Jul 2005 16:40:34 +0000 (GMT) (envelope-from gad@FreeBSD.org) Received: from smtp2.server.rpi.edu (smtp2.server.rpi.edu [128.113.2.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id E9E9B43D4C for ; Thu, 28 Jul 2005 16:40:33 +0000 (GMT) (envelope-from gad@FreeBSD.org) Received: from [128.113.24.47] (gilead.netel.rpi.edu [128.113.24.47]) by smtp2.server.rpi.edu (8.13.0/8.13.0) with ESMTP id j6SGeUsu021057; Thu, 28 Jul 2005 12:40:32 -0400 Mime-Version: 1.0 Message-Id: In-Reply-To: <1136.217.37.3.201.1122541837.squirrel@www.orbweavers.co.uk> References: <1559.192.168.0.10.1122502486.squirrel@192.168.0.5> <1136.217.37.3.201.1122541837.squirrel@www.orbweavers.co.uk> Date: Thu, 28 Jul 2005 12:40:29 -0400 To: martin@orbweavers.co.uk From: Garance A Drosehn Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-CanItPRO-Stream: default X-RPI-SA-Score: undef - spam-scanning disabled X-Scanned-By: CanIt (www . canit . ca) on 128.113.2.2 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 16:40:34 -0000 At 10:10 AM +0100 7/28/05, martin@orbweavers.co.uk wrote: >Garance wrote: > > 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'? Well, I also have versions that use an echo instead of printf. The printf just makes it easier to have a "pretty" output. The problem with using a plain 'echo *' is that there are several different inputs which will produce the same output. Compare: echo a b and echo "a b" or echo "a b" and echo "a b " The outputs from `echo' will look the same, but the arguments to the program are very different. That's why my script lists out the exact arguments, with their lengths. I did that because sometimes those details matter. I have solved problems similar to the one which is frustrating you by using this kind of script. -- Garance Alistair Drosehn = gad@gilead.netel.rpi.edu Senior Systems Programmer or gad@FreeBSD.org Rensselaer Polytechnic Institute; Troy, NY; USA