bash variable substitution...
Peter Lavender
plaven at bigpond.net.au
Wed Jan 1 12:08:40 EST 2003
Hi Everyone,
the ldapsearch command gets rather long, so I figured that a wrapper
script was in order.. however the problem is I can't seem to get the
variable substitution right.
Here's the script.. edited to protect the guilty.. :)
#!/bin/sh
echo "Searching for: $1"
name=$1
cmd="ldapsearch -x -s sub -h ldap -b 'ou=People'
'(|(sn=${name}*)(cn=*${name}*))'"
echo -e "This is command:\n${cmd}"
$cmd
Now when it runs I get an error about invalid DN.. which is openldap
complaining here.
Yet, if I copy and paste the command from the command line, it works
fine.
The problem here I think is the use of the single quotes around the
filter where I want to put the parameter from the command line in. Or
how I'm trying to execute the variable $cmd and get the output.
Pete
More information about the linux
mailing list