javaboy
javaboy

Reputation: 99

How to pass command line specific parameters to a batch file?

I want pass specific parameters(aaa|bbb|ccc) but it's not working.

Here's what the command line looks like:

    test.bat aaa|bbb|ccc

and test.bat looks like:

    echo %1

but its not working cuz test.bat receive only 'aaa'. how can I pass whole parameter 'aaa|bbb|ccc'?

ps. I must use this format : 'aaa|bbb|ccc' there is no option to change like aaa_bbb_ccc.. etc.

Upvotes: 1

Views: 142

Answers (2)

lit
lit

Reputation: 16266

The VERTICAL BAR is the pipe character to command.com and cmd.exe. If you want to use is literally, it must be escaped using a CARET.

K:>echo aaa^|bbb^|ccc
aaa|bbb|ccc

Actually, I think I might prefer the quoting suggestion as it appears to work under bash and perhaps other shells.

$ echo "aaa|bbb|ccc"
aaa|bbb|ccc

$ echo 'aaa|bbb|ccc'
aaa|bbb|ccc

Upvotes: 1

Liam Mulder
Liam Mulder

Reputation: 26

Using the "|" means you use the pipe function. http://ss64.com/nt/syntax-redirection.html

You should use "aaa|bbb|ccc" so that it will read everything between the quotation marks.

I hope it helps

Upvotes: 1

Related Questions