One of the more annoying and unfortunately common emails I tend to get sent to me goes something like…
Dear joe,
Your tool xxx must have a bug because it doesn’t work when I have a space in the name[1]. I guess you must not have tested for this situation. When do you think you can fix it?
 thanksÂ
[1] Or an ampersand or a pipe or a greater than or less than or several other characters.
The issue here is that it seems a large number of people have no clue how to actually use the command line and assume because something doesn’t work in the manner they expect, my utilities must be at fault. This is especially funny with characters that cause the OS to actually throw errors itself that someone will attribute to my utilities, for instance
F:\>adfind -default -f name=|something
‘something’ is not recognized as an internal or external command, operable program or batch file.
You will note the similarity to the error here
F:\>deerrrrt da derrrrrrr
‘deerrrrt’ is not recognized as an internal or external command, operable program or batch file.
This error is clearly not from adfind for anyone who has a clue about the command prompt. I am sorry if this is not clear to you or your friends. Praise be to Kernighan and Ritchie this actually is not my concern except when someone emails me and complains because the tool isn’t working and I take time to respond. I am now proactively taking the matter into my own hands and writing this blog entry for everyone to refer to so that those responses, if I choose to respond at all, will take all of about 5 seconds.
So how do you fix this problem? With quotes…. You quote the parameters that should be taken together as a single parameter like so
F:\>adfind -default -f “name=|something”
AdFind V01.31.00cpp Joe Richards (joe@joeware.net) March 2006
Using server: r2dc2.test.loc:389
Directory: Windows Server 2003
Base DN: DC=test,DC=loc
0 Objects returned
You can actually do this for all parameters on the command line all of the time if the whole concept is confusing then you don’t have to be as worried you didn’t do it when you needed to like so
F:\>”adfind” “-default” “-f” “name=|something”
AdFind V01.31.00cpp Joe Richards (joe@joeware.net) March 2006
Using server: r2dc2.test.loc:389
Directory: Windows Server 2003
Base DN: DC=test,DC=loc
0 Objects returned
Sure it is longer and tougher to type but much easier than things not working and then you having to email someone else to tell you how to do it. Just remember that the application and parameters are delimited by the space character. I.E. If there is an unquoted space, it means the next non-space character is the start of a new parameter. Think of it this way
“application” “parameter1” “parameter2” … “parameter(n)”
If you need to actually embed quotes, you need to escape the quote character with a slash. If you don’t know what that means, I am sorry. Look at buying a book on using the command prompt. I don’t have any recommendations but I assume somewhere someone has documented how to do things from the command prompt and is getting money for it. You need to pay that money.
So my suggestion, if you are going to use the command line, understand what you are doing. If you have a job as an admin, you probably already should have this understanding and if you don’t, I suggest you get it. I am not saying you need to become the perl guru of all time, but you need to be able to at least use the command prompt and have a clue what is going on when you do. Take pride in your career and excel in it, someone shouldn’t have to spoon feed you. Administration positions are professional positions.
Primarily I have put this post out here so I can answer several emails a week with a simple link. If you received this link in an email from me, this is the entire help you will get with the subject. If you are absolutely positive that you are right and whichever tool is broken, explain better what the actual issue is when you email me again because the time I spent on your previous email made me think this was the issue.Â
  joe
Â
While I basically agree with your post, I think some blame should lie with MS’s brain-dead command line. Hopefully, PowerShell or whatever it is they’re calling Monad these days, will do a better job of things.
How can a command line interpreter determine whether or not a space means a new param or is part of the same param? Only way around that is to change the entire parameter passing mechanism. Personally I kind of like it.
I am not sure how much impact MONAD will really have. I hope it helps out but I am not on the love boat with it yet. I don’t think it will have near the excited penetration that some hope for… just like dotNET.
joe
@Fred:
peo ple w ho l ike spaces a re s ome j iv e as s fol ks e s