Saved Bookmarks
| 1. |
Solve : De Refferencing command line args? |
|
Answer» Ok I am trying to make a batch file, where one its many tasks is to run this file call ldapsearch. The command line call looks like: ldapsearch -x -b "dc=utoronto,dc=ca" "(login=sham)" password Now in this call 'login' is the criteria for the search and 'sham' is the value. In my script these two have to be taken in as command line arguments. SO %1 and %2 then so in my script I tried to do ldapsearch -x -b "dc=utoronto,dc=ca" "("%1"="%2")" password but that did not work since the computer gets ldapsearch -x -b "dc=utoronto,dc=ca" "(""login""=""sham")" password is there any way i can DE refference the command line arguments without the surrounding " ", or is there another better way of doing this. Thank youDont surround the params with quotes --- ldapsearch -x -b "dc=utoronto,dc=ca" "(%1=%2)" password If there were spaces in the params, you would need to put the quotes around the params on the commandline, which you could remove before supplying to the ldapsearch commandline Graham I'm sure it is possible. Just a case of getting all the quotes and percentage signs right... Have you tried the following...? ldapsearch -x -b "dc=utoronto,dc=ca" "(%1=%2)" password Seems to work for me on Windows XP. (Obviously I get an error because 'ldapsearch' is not recognized.) Code: [Select]D:\>type TEST.bat ldapsearch -x -b "dc=utoronto,dc=ca" "(%1=%2)" password D:\>TEST login sham D:\>ldapsearch -x -b "dc=utoronto,dc=ca" "(login=sham)" password 'ldapsearch' is not recognized as an internal or external command, operable program or batch file. D:\> Hope that helps, JamesThanks guys works just fine.OOps i thought it worked fine!! Till i tested it this morning guys. Seems that the STRING get put as ldapsearch -x -b "dc=utoronto,dc=ca" "("login"="shammer")" pass which MIRACULOUSLY works fine unless there is a space SOMEWHERE say instead of shammer i have "sham rock". THen the whole thing goes to *censored*. Is there some way i can collapse the command line arguments a single compact string like "(login=shammer)" THANKS guys Never mind guys I figured it out!! I just put %1=%2 instead of "(%1=%2)" |
|