summaryrefslogtreecommitdiff
path: root/gnu/libexec/uucp/contrib/Login.PortSel
blob: d8c3a6643a6650d82844607888cc8dc087d42ff5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!xchat
# @(#) Login.PortSelUnix V1.0 Tue Sep  1 14:57:05 1992 (Bob Denny)
#
# NOTE: Untested with xchat V1.1. Taken from DECUS UUCP.
#
# From: "Kent C. Brodie" <moocow!brodie@CSD4.MILW.WISC.EDU>
#	uucp:	{uunet!marque,csd4.milw.wisc.edu}!moocow!brodie  
# special script for "uwmcsd4", have to go through a port selector (and then
# log in via standard Unix procedures).  
#
# Also included is the ability to wait in the port selector queue.
# Be forwarned that the debug log can get pretty big depending on 
# how many times you "wait" in the queue.
# (C) 1989 Kent C. Brodie - Medical College of Wisconsin

# P0 is systemname , P1 is username, P2 is password. 

	zero

# send a CR to get the selector's attention.  Sleep a little bit
# due to large login text of selector.   It sends "Which System?"
# when it's ready. 

getprtslct:
	count
	ifgtr	noprtslct	6
	break
	send	\r
	sleep	2000
	flush
	expect	prtslctok	ystem?
	timeout	getprtslct	15000

noprtslct:
	logerr	Sent cr, no "Which System?" from port selector
	failed

# Send the system name.  We either get "OK" (connected), or we
# get "No ports available, would you like to wait?" (wait in queue)

prtslctok:
	zero
	sendstr	0
	send	\r
	expect	connected	OK
	expect	prtslctwait	wait?
	timeout	noconnect	10000

# Usually we get "nn Your place in queue" messages.  JUST in case we
# get a free port right away, check for 'Are you ready?' as well.

prtslctwait:
	zero
	send	Y\r
	expect	prtslctque	queue
	expect	prtslctrdy	ready?
	timeout	prtwaitbad	70000

prtwaitbad:
	logerr	Sent "Y" to wait in queue, did not get valid response.
	failed

# Here's where we wait in the queue.  The port selector sends us a status
# message about once a minute.  We either get "nn Your place in queue"
# or we get "System Available.  Are you Ready?". 
# If something goes wrong, we time out waiting for either response.
# The reason we don't sleep for 40-50 seconds is because as SOON as the
# port is ready, it informs us.  If we wait too long, it drops us.
# This setup is laid out for a maximum of 20 "tries" which is ABOUT
# 20 minutes.   Note:  This constant retrying can make log files
# kind of big....

prtslctque:
	count
	ifgtr	prtslcttry	20
	expect	prtslctque	queue
	expect	prtslctrdy	ready?
	timeout	noportwait	70000

prtslcttry:
	logerr	Too many (20) wait/retries -- queue too busy.
	failed

prtslctrdy:
	send	Y\r
	expect	connected	OK
	timeout	noconnect	20000


noportwait:
	logerr  Timed out awaiting place in port queue
	failed

noconnect:
	logerr	Sent system name, no "OK" from selector
	failed

# standard Unix login stuff.  Send cr, expect "ogin:", if no, send a break 
# (which tells Unix to try the next bit rate) and try again.  

connected:
	send	\r
	zero
	goto	waitlogin

sendbreak:
	count
	ifgtr	nolgi		6
	flush
	break

waitlogin:
	expect	gotlogin	ogin:
	timeout	sendbreak	5000

nolgi:
	logerr	No login: prompt
	failed

gotlogin:
	sendstr	1
	send	\r
	expect	gotword		word:
	timeout	nopwd		10000

nopwd:
	logerr	No password: prompt
	failed

gotword:
	sendstr	2
	send	\r
	success