	SUBROUTINE GETCMD(cmd_type, options)
	IMPLICIT INTEGER (A-Z)

	INTEGER*4 str$trim, str$position, icode, for_len, option_len
	CHARACTER foreign_line*512, cmd_type*6, running_user*31
	CHARACTER*256 options(4)
	EXTERNAL netmailcli, netmail_badinput, netmail_noinput
C
        PARAMETER CLI$G_PRESENT   = '0003FD19'X
        PARAMETER CLI$L_PRESENT   = '0003FD31'X
        PARAMETER CLI$G_NEGATED   = '000381F8'X
        PARAMETER CLI$L_NEGATED   = '00038230'X
        PARAMETER CLI$_ABSENT     = '000381F0'X
C
C	Set default strings and logicals.
C
	foreign_line = ' '
	options(1)   = ' '
	options(2)   = ' '
	options(3)   = ' '
	options(4)   = ' '
	cmd_type     = ' '
	running_user = ' '
C
C	Get foreign command line.
C
	icode = LIB$GET_FOREIGN(foreign_line,'Netmail: ')
	icode = STR$TRIM(foreign_line, foreign_line, for_len)
	if (for_len.eq.0) CALL LIB$SIGNAL(netmail_noinput)
C
C	Let DCL parse it.
C
	icode = CLI$DCL_PARSE('netmail '//foreign_line(1:for_len),netmailcli)
C
C	Get Command type (SET/SHOW/DELETE/LIST/COMPARE). Default = SHOW.
C
	icode = cli$present('p1')
	if (icode) then
	icode = cli$get_value('p1', cmd_type)
	  if (cmd_type(1:2).eq.'CO') cmd_type = 'COMPAR'
	  if (cmd_type(1:2).eq.'DE') cmd_type = 'DELETE'
	  if (cmd_type(1:2).eq.'LI') cmd_type = 'LIST'
	  if (cmd_type(1:2).eq.'SE') cmd_type = 'SET'
	  if (cmd_type(1:2).eq.'SH') cmd_type = 'SHOW'
	else
	 cmd_type = 'SHOW'
	Endif !End of p1 (SET/SHOW/DELETE) check.
C
C	Get USERNAME input.
C
	icode = cli$present('USERNAME')
	if (icode) then
	icode = cli$get_value('USERNAME', options(1))
	icode = str$trim(options(1), options(1), option_len)
	if (option_len.lt.3) CALL LIB$SIGNAL(netmail_badinput)
	Endif !Username check.
C
C	Get NAME input.
C
	icode = cli$present('NAME')
	if (icode) then
	icode = cli$get_value('NAME', options(2))
	icode = str$trim(options(2), options(2), option_len)
	if (option_len.lt.3) call LIB$SIGNAL(netmail_badinput)
	Endif !Name check.
C
C	Get PERSONAL input.
C
	icode = cli$present('PERSONAL')
	if (icode) icode = cli$get_value('PERSONAL', options(3))
C
C	Get FORWARD node address.
C
	icode = cli$present('FORWARD')
	If (icode) then
	icode = cli$get_value('FORWARD', options(4))
	Else
	 If(icode.ne.229880) then
	 CALL GET_USERNAME(running_user)
	 options(4) = running_user
	 Endif
	Endif
C
	return
	end
