암호를 묻는 방법 (즉, 입력 에코가 없음)을 찾고 있습니다. WebSphere 7.0.0.19 wsadmin에서 jython을 사용하고 있습니다.WebSphere wsadmin jython - 암호를 묻는 메시지
나는 그것을 찾았다 - 가져 오기 getpass 또는 import termios를 사용하는 것이 가능하다. (하지만 "no module named ..."예외가 발생한다.)
어쨌든 비밀번호를 묻는 방법은 없나요?
감사합니다.
암호를 묻는 방법 (즉, 입력 에코가 없음)을 찾고 있습니다. WebSphere 7.0.0.19 wsadmin에서 jython을 사용하고 있습니다.WebSphere wsadmin jython - 암호를 묻는 메시지
나는 그것을 찾았다 - 가져 오기 getpass 또는 import termios를 사용하는 것이 가능하다. (하지만 "no module named ..."예외가 발생한다.)
어쨌든 비밀번호를 묻는 방법은 없나요?
감사합니다.
다음 코드를 사용할 수 있습니다. 기본적으로 Java 콘솔() (있는 경우 may not be present 항상 표시됨)이 있으면 raw_input() 및 암호 마스킹 논리를 사용합니다. 이 암호를 마스크하지 않기 때문에
가raw_input("")
myPass = raw_input("Please enter a password: ")
이 완벽하지는 않지만 작업을 수행합니다
# if console is not available (ex: when invoked from a shell script or another java process)
# we need to fall back to use raw_input, but we should mask the password if we use it
import sys, thread, time, threading
from java.lang import String
def getPass(stream=None):
console = java.lang.System.console()
if console is None:
global p_stopMasking
if not stream:
stream = sys.stderr
try:
p_stopMasking = 0
threading.Thread(target=_doMasking,args=(stream,)).start()
password = raw_input()
p_stopMasking = 1
except Exception, e:
p_stopMasking = 1
print "Error Occured"
print e
exit()
else:
password = console.readPassword()
return String.valueOf(password)
def _doMasking(stream):
while not p_stopMasking:
stream.write("\010*")
#stream.write("\n")
stream.flush()
time.sleep(0.01)
def populateCredentials():
global username
global password
print 'Enter username:'
username = raw_input();
print 'Enter password:'
password = getPass(sys.stdout);
# start main
print 'start program...'
p_stopMasking= 1
username = None
password = None
populateCredentials()
print 'username is : ' + username
print 'password is : ' + password
다음은 나를 위해 일했다. 어떤 이유로 첫 번째 "raw_input"호출을 지정하지 않으면 두 번째 스크립트에서 스크립트가 차단되지 않습니다.
내 대답이 유용 했습니까? 그걸 묻는 질문 있어요? – Mani
이 질문이 더 이상 필요하지 않더라도 제공된 답변을 확인하고 질문에 답변 할 때 대답을 받아야합니다. 제발 그렇게 해. – Mani