(LOGO.JPG) Python for OpenVMS

(go to: table of contents, index, list of pyvms, next: CRTL_FROM_VMS)


PYLIB_GETPASS - get password from terminal


This is a helper routine for [.LIB]GETPASS.PY.

Format:

    password = pyvms.pylib_getpass (fileno, prompt)
Returns:
password
The password that was entered - it is not echoed.
Arguments:
fileno
'file number' from the C RTL.
Internally this is translated into an OpenVMS file specification and an I/O channel is SYS$ASSIGNed to it. If the I/O channel is not assigned to a terminal device an exception is raised - see the examples section.
password
The password string that is entered.

Examples:

>>> import pyvms
>>> import sys

>>> l_fileno = sys.stdin.fileno()
>>> print l_fileno
0
>>> t_password = pyvms.pylib_getpass (l_fileno, 'PwDStr:')
PwDStr:                    <-- cursor is directly after ':'
>>> print repr (t_password)
'InPUt'
>>>


>>> # try a file
>>> filobj = open ('python_vms:setup.com', 'r')
>>> l_fileno = filobj.fileno()
>>> print l_fileno
3
>>> t_password = pyvms.pylib_getpass (l_fileno, 'PwDStr:')
Traceback (innermost last):
  File "<stdin>", line 1, in ?
pyvms.error: (324, '%SYSTEM-F-IVDEVNAM, invalid device name')
>>> filobj.close()   # cleanup
>>>

Note: SS$_IVDEVNAM has been deliberately choosen.


>>> l_fileno = 9
>>> t_password = pyvms.pylib_getpass (l_fileno, 'PwDStr:')
Traceback (innermost last):
  File "<stdin>", line 1, in ?
pyvms.error: (9, 'bad file number')
>>>


>>> # test with [.LIB]GETPASS.PY
>>>
>>> import getpass
>>> t_password = getpass.getpass ('PRoMpT:')
PRoMpT:
>>> print repr(t_password)
'DAtA'
>>>

(go to: table of contents, index, list of pyvms, next: CRTL_FROM_VMS)

22-JAN-2000 ZE.