我想在输入时隐藏像******这样的输入密码。 这是我创建的代码
set valid_password = $<
set password = '1234'
if ( password != valid_password) then
echo 'please re-enter password'
else
if (password == valid_password) then
echo 'password is correct'
end
exit
答案 0 :(得分:1)
如果您可以接受任何密码字符(而不是*),那么以下CSH将循环直到输入有效密码:
#!/bin/csh
set valid_password = '1234'
while (1)
echo -n "Enter your password: "
set password = $<
if ("$password" == "$valid_password") break
echo "Incorrect password!"
end
echo "Goody!"