ecu - SCO XENIX V/{2,3}86 Extended CU part 47/47

Warren Tucker wht at tridom.uucp
Thu Oct 12 05:22:38 AEST 1989


---- Cut Here and unpack ----
#!/bin/sh
# this is part 47 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file models/unixlogin.ep continued
#
CurArch=47
if test ! -r s2_seq_.tmp
then echo "Please unpack part 1 first!"
     exit 1; fi
( read Scheck
  if test "$Scheck" != $CurArch
  then echo "Please unpack part $Scheck next!"
       exit 1;
  else exit 0; fi
) < s2_seq_.tmp || exit 1
echo "x - Continuing file models/unixlogin.ep"
sed 's/^X//' << 'SHAR_EOF' >> models/unixlogin.ep
X#:07-09-1989-23:50-wht-add breaks
X#:06-28-1989-19:36-wht-use named variables
X#:06-25-1989-13:56-wht-new do command syntax
X#:06-25-1989-12:33-wht-new if/while syntax
X#:06-23-1989-19:46-wht-improved hayes dialer reduces need to report dial fail
X#:06-19-1989-22:50-wht-use while and if statements
X#:06-14-1989-15:58-wht-add login capability when already connected
X#:06-11-1989-23:37-wht-creation
X
X	mkvar $i_csave,$i_ltimeout,$i_retries
X
X	$i_csave = %colors
X	$i_ltimeout = 30 # 3 seconds wait for first login prompt
X	$i_retries=3
X
X	color red;    echo -n '\nauto-logon to '
X	color yellow; echo -n %argv(1)
X	color red;    echo    ' on '+%date+' at '+%time+'\n'
X
X	ifi %argc < 5	# not enough args
X	{
X		color red
X		echo %argv(0)+' needs 5 arguments (got '+%itos(%argc)+')'
X		goto SORRY
X	}
X	mkvar $i_breaks
X	ifi %argc > 5 $i_breaks = %stoi(%argv(5))
X
X	ifi %conn == 0 goto DIAL
X
X	ifs %rname == %argv(1)
X	{
X		color brown;  echo -n 'already connected to '
X		color yellow; echo    %rname
X		send ''
X		goto SEND_BREAKS
X	}
X
XHANGUP
X	ifi %conn <> 0 echo 'hanging up on '+%rname; hangup
X
XDIAL
X	color green
X	dial %argv(1); set $i1=$i0 #save dial result in $i1
X	ifi $i1 == 2 color red; echo 'interrupted'; goto SORRY
X	ifi $i1 != 0 goto SORRY
X
X# send breaks?
XSEND_BREAKS
X	ifi $i_breaks > 0
X	{
X		whilei $i_breaks > 0
X		{
X			color blue; echo 'sending break to remote'
X			nap 20
X			lbreak
X			$i_breaks = $i_breaks - 1
X		}
X		flush
X		lookfor '\n' 50
X	}
X
X# get login prompt from remote UNIX system: "login: "
XGET_LOGIN_PROMPT
X	set $i_retries = 6		# retry count
X
XGET_LOGIN_PROMPT_RETRY		# retry get login prompt
X	whilei $i_retries > 0
X	{
X		color cyan
X		lookfor -e 'login: ' $i_ltimeout
X		ifi $i0 == 1 break			# go send username
X		$i_ltimeout = 50			# later login waits 5 secs
X		set $i_retries = $i_retries - 1			# read and decrement retry
X		ifi $i_retries == 0 goto SORRY	# but not if retry exhausted
X		color yellow
X		echo 'sending prompt stimulus'
X		color green
X		send '' # kick off another login prompt
X	}
X
X# give username to remote
XSEND_USERNAME
X	nap 3 # system not always ready when it says
X	send %argv(2)
X
X# get password prompt: "Password:" 
XGET_PASSWORD_PROMPT
X	lookfor -e 'Password:' 50
X	ifi $i0 != 1		# did not find 'Password: '
X	{
X		send ''
X		gotob GET_LOGIN_PROMPT_RETRY
X	}
X
X# send the password
X	nap 3 # system not always ready when it says
X	send %argv(3)
X
X# get term type prompt "TERM = (ansi) "
X# also handle incorect login retry and 'Sorry' hangup indication
XGET_TERMTYPE_PROMPT
X	ifs %argv(4) == ''	# if no term type, don't wait for prompt
X	{
X		$i0 = 0			# return good status
X		goto SETCOLOR_AND_RETURN_STATUS
X	}
X	lgets -re $s0 100 50 ') '
X	ifi %instr($s0,'Sorry') > 0 hangup;goto SORRY
X	ifi %instr($s0,'incorrect') > 0		# exhausted retry?
X	{
X		set $i_retries=$i_retries-1
X		ifi $i_retries > 0 goto SEND_USERNAME
X		goto SORRY
X	}
X# send terminal type
X	ifi %instr($s0,'TERM') < 0
X		lookfor -e ') ' 30
X	send %argv(4)
X	lookfor -e '\n' 50
X	set $i0=0
X	goto SETCOLOR_AND_RETURN_STATUS
X
X# procedure failed
XSORRY
X	set $i0=1
X
XSETCOLOR_AND_RETURN_STATUS
X	icolor $i_csave
X	ifi $i0 == 0 ifi %conn !=0 prompt %rname+' >'
X	return $i0
X
X# vi:set tabstop=4 shiftwidth=4:
SHAR_EOF
echo "File models/unixlogin.ep is complete"
chmod 0644 models/unixlogin.ep || echo "restore of models/unixlogin.ep fails"
rm -f s2_seq_.tmp
echo "You have unpacked the last part"
exit 0
-- 
-------------------------------------------------------------------
Warren Tucker, Tridom Corporation       ...!gatech!emory!tridom!wht 
Ker-au'-lo-phon.  An 8-foot partial flue-stop, having metal pipes
surmounted by adjustable rings, and with a hole bored near the top
of each pipe, producing a soft and "reedy" tone.



More information about the Alt.sources mailing list