![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Remove double quotes | deepakwins | UNIX for Dummies Questions & Answers | 3 | 05-30-2008 11:53 AM |
| Double quotes or single quotes when using ssh? | password636 | Shell Programming and Scripting | 3 | 05-29-2008 08:52 PM |
| Displaying double quotes using Perl | kbdesouza | Shell Programming and Scripting | 2 | 12-10-2007 11:18 AM |
| put double quotes for a column | sumeet | Shell Programming and Scripting | 3 | 05-09-2007 07:20 PM |
| How do I insert double quotes | dsean | Shell Programming and Scripting | 3 | 05-26-2006 01:28 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Double Quotes within a variable
This is a totally dumb newbie question, but I have not been able to find t he answer in the BASH book or online.
I am trying pass a double quoted variable to the command line. variable = "-b \"dc=example,dc=com\"" When I run sh -x the variable comes out as '-b "dc=example,dc=com"' is should be: -b "dc=example,dc=com" the single quotes around the double quotes is is breaking the command. I have tried ${variable} \"${variable}\" $variable "$variable" \"$variable\" None of come up with the desired quote. Any input is appreciated! -Rob |
|
||||
|
It echos fine but does not run fine.
You have to run it in a script.
#--------- #!/bin/bash variable="-b \"dc=example,dc=com\"" ldapsearch $variable echo This is echoed: $variable #---------- when you run sh -x to it this is the result. + variable=-b "dc=example,dc=com" + ldapsearch -b '"dc=example,dc=com"' ldap_sasl_interactive_bind_s: Can't contact LDAP server + echo This is echoed: -b '"dc=example,dc=com"' This is echoed: -b "dc=example,dc=com" You will notice that is echos fine but when it is run it has the single quotes. Ignore the ldap error this is just an example of how BASH add single quote when the command is run. |
|
||||
|
I may have misunderstood your problem and I've gone a bit 'quote-blind' looking at your output, but it seems to me the single quotes are there because you're running the script in debug mode and the shell is using them to explain what is being echoed. Or have I missed the point?
|
|
||||
|
Not sure
I think you might be right. Below are the results from the actual script. The thing that screws me up is i CAN copy the echoed command into the command prompt and it works. I am at a loss. The single quote in the debug lines make no sense though.
#variables base="-b \"dc=junk,dc=example,dc=stuff\"" # Replace with your domain name user="-D \"cn=ESX Ldap Account,OU=Linux,dc=junk,dc=example,dc=stuff\"" # Running Echo Command + echo ldapsearch -x -LLL -H ldap://junk.example.stuff -b '"dc=junk,dc=example,dc=stuff"' -D '"cn=ESX' Ldap 'Account,OU=Linux,dc=junk,dc=example,dc=stuff"' -w password -u -tt -T /usr/LDAP/Member '"CN=Jon' H. 'Doe"' samAccountName # Result from Echo ldapsearch -x -LLL -H ldap://junk.example.stuff -b "dc=junk,dc=example,dc=stuff" -D "cn=ESX Ldap Account,OU=Linux,dc=junk,dc=example,dc=stuff" -w password -u -tt -T /usr/LDAP/Member "CN=Jon H. Doe" samAccountName # Runing Ldapsearch comman + ldapsearch -x -LLL -H ldap://junk/example.stuff -b '"dc=junk,dc=example,dc=stuff"' -D '"cn=ESX' Ldap 'Account,OU=Linux,dc=junk,dc=example,dc=stuff"' -w password -u -tt -T /usr/LDAP/Member '"CN=Jon' H. 'Doe"' samAccountName |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|