Solved

Question about .bashrc function syntax

Posted on 2008-10-29
7
484 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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.

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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 …
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
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…

734 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