Solved

Question about .bashrc function syntax

Posted on 2008-10-29
7
479 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

831 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