My .bat file command to get user input from command line is
set /p weblogicpassword=Enter weblogic password:%=%
My .sh file command to get user input from bash script is
echo -n "Enter weblogic password: "
read weblogicpassword
Now when we enter some values for password, those values are visible in command line. How we can get the password values from command line which should be invisible to users like **
Here is a solution for Windows 32 bit.
For bash its
read -s
.-s Silent mode. If input is coming from a terminal, characters are not echoed.
For batch it seems to be more complicated.
Read about it here: Can I mask an input text in a bat file
I read all answers and I fixed one.
This code asks user for password. You can change password in
if "%password%"=="SuperUser"
.It checks input and if input is valid (SuperUser), it goes to label
1
.Here is the code:
By using powershell, we can achieve this in 32 as well as 64 bit.
By using this we can get password with *** in command line
In bash script we can achieve this by using below code.
The options of the read command are: -p : Prompt string. -r : Don't use backslash as escape character. -s : Silent mode, inputs are not echoed. -n 1 : Number of character to input.
read returns 0 unless \0 is encountered, and the character the user types is placed into the char variable.
The IFS= part clears the IFS variable, which ensures that any space or tab characters that you type are included in the password rather than being parsed out by read.