Solved

Question about .bashrc function syntax

Posted on 2008-10-29
7
480 Views
Last Modified: 2013-12-26
Can't get $1 input to work in the following function. Need assistance with syntax. Thanks!

function lookup ()
{ /usr/bin/ldapsearch -1TL -h `hostname` -p 389 -D 'cn=Directory Manager' -j /root/pw_`hostname`.txt -b 'dc=ourcompany,dc=com'
 '(uid=$1)'; }
0
Comment
Question by:pzxkys
  • 3
  • 3
7 Comments
 
LVL 5

Expert Comment

by:zmo
ID: 22830397
use double quotes instead of single quotes.

'$1' is equivalent to "\$1"
0
 

Author Comment

by:pzxkys
ID: 22830913
Tried '(uid="$1")'. No luck.
0
 
LVL 40

Accepted Solution

by:
omarfarid earned 125 total points
ID: 22830974
don't put single quotes around

try

(uid="$1")

or

"(uid=$1)"
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 5

Expert Comment

by:zmo
ID: 22831337
like omarfarid said,

'(uid=$1)' means "(uid=\$1)"
and
'(uid="$1")' means "(uid=\"\$1\")"

double quotes contain strings and code that can be interpreted,
single quotes contain only text.

what I meant with my example was to pinpoint what was wrong in your whole statement.
Whatever is around between the quotes and $1, if you use single quotes around $1, you'll get $1 and not what it contains.
0
 

Author Closing Comment

by:pzxkys
ID: 31511114
This worked : "(uid=$1)".
Thanks guys for your quick response and excellent assistance! And thanks to the other expert feedback explaining how ' and " really works in bash!

0
 
LVL 5

Expert Comment

by:zmo
ID: 22832587
ugh !?
_I_ gave the solution !
and you don't give me any points or split the points ?
0
 

Author Comment

by:pzxkys
ID: 22832736
Sorry about that zmo! I was hurrying too much. I actually got the solution from omarfarid first. But to be fair I think you both were very helpful. If you know how to split the points after the fact, let me know and I'll be happy to do that.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question