Solved

Question about .bashrc function syntax

Posted on 2008-10-29
7
482 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
Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

 
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unix process listing into CSV format 3 46
RoboCopy to Changing External Drives 2 60
Debugging a shell script 3 34
LINUX Field Separators 7 55
Utilizing an array to gracefully append to a list of EmailAddresses
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…

679 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