DOS BAT Command: How to accept semi-colon as an input
I am fairly new in writing BAT files. So, I need to create a BAT file in which it will accept username and password from the command prompt and use the values to process certain SQL commands in ORACLE. This is easy, I had done so in which it will prompt user to enter the ORACLE username, password and DB. They are respectively value1, value2 and value3.
The problem here is that, the ORACLE password contains semi-colon. And when the semi-colon is entered in t开发者_开发问答he CMD prompt, somehow the value is incorrect. E.g. the password is "abc;cde". Somehow, value2 only reads as "abc". Can someone help? I had tried to enter double quotes during the prompting, but it is still the same. Besides, I rather not to have the user to enter double quotes during the prompting as that may confuse with the actual password.
Please assist.
Your question is a bit short on details.
Are you sure your read of the password actually reads the ";" part ?
I can't tell from your question if the ";" isn't read into "value2" or if it is actually in "value2" but not handed to the Oracle client properly. Without more details it's impossible to give a proper answer.
For the record:
set /P VALUE2=
echo %VALUE2%
Will read a text containing a ";" and echo it back to screen.
You can access the ;
only with %*, bot with %1
, %2
or %<n>
.
But even then it's a bad idea to try to read a password from the command line, which can contain special characters, as it's not possible to access all allowed/possible passwords.
Pwd: a&b|c^w%cd%
is absolutly not accessible this way.
I would also prefer the tip of Tonny to use set /p
inside of the batch to enter a password.
精彩评论