On Aug 22, 2008, at 05:26 , Vladimir Sokolov wrote:
2008/8/22, Bill Bumgarner <[EMAIL PROTECTED]>:On Aug 22, 2008, at 1:00 AM, Vladimir Sokolov wrote:Hello All, I am working on a command line tool. I use NSArray *params = [[NSProcessInfo processInfo] arguments] to get a list of command line parameters. Then I use NSString *param1 = [params objectAtIndex:1]; to get it. But when I pass for example >...myapplication test$test param1 got "testest" instead of ""test$test" It means as I understand that $ is interpreted as special character. So my question is how to pass a parameter with $ inside? And are there any other special characters which are interpreted as special one?To be clear, this has nothing to do with NSString and everything to do withhow the shell parses command lines.As Michael D alluded to, the shell is seeing $test and "expanding" the $t to be the value of -- typically -- the environment variable 't', whichdoesn't have a value and, thus, you end up with 'testest'. That is, all argument processing has been completed long before your command line tool is even launched.Now, the syntax and rules for substitution change depending on the shellused and how your command line tool is launched. As well, APIs forlaunching processes such as NSTask, popen(), system(), and the variousfork()/exec*() combinations may or may not behave similarly. So -- the real questions: What is launching your command line tool? Do you really need an argument with a $ character in it?Most command line tools avoid such characters for the reasons stated above.Have you read this book? http://tinyurl.com/6kxxgc b.bumThanks for your messages. Now I see my problem ( Learn Unix! :))The $ character is part of the user password, that is why I need to use it.Now for the test I am launching my tool in bash.
If you're using bash you can surround the argument in single quotes (e.g., 'test$test') and it won't do any expansion.
However, it's a really bad idea to pass a password on the command line in Unix in general because any application can read your
process's argument list without any special privileges. Jason
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]