Solved

Question about .bashrc function syntax

Posted on 2008-10-29
7
477 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Utilizing an array to gracefully append to a list of EmailAddresses
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…
This video discusses moving either the default database or any database to a new volume.

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now