Debian Codegraph @

extras/unixlogin

raw
1 # Generic UNIX login script.
2 # Can be used to automatically login to almost every UNIX box.
3 #
4 # Some variables.
5 set a 0
6 set b a
7 print Trying to Login..
8 # Skip initial 'send ""', it seems to matter sometimes..
9 goto skip
10 loop1:
11 # Send loginname not more than three times.
12 send ""
13 inc a
14 skip:
15 if a > 3 goto failed1
16 expect {
17 "ogin:"
18 "assword:" send ""
19 "NO CARRIER" exit
20 timeout 60 goto loop1
21 }
22 loop2:
23 send "$(LOGIN)"
24
25 # Send password not more than three times.
26 inc b
27 if b > 3 goto failed1
28 expect {
29 "assword:"
30 "ogin:" goto loop2
31 timeout 60 goto loop2
32 }
33 send "$(PASS)"
34 # If we don't get "incorrect" within 3 seconds, it's probably OK.
35 # If they ask for a terminal, we are logged in. Tell them we're
36 # using vt100.
37 # If we get the bash prompt, send them the screen geometry.
38 expect {
39 "TERM=" goto wantterm
40 "incorrect" goto loop1
41 "bash$" goto screengeom
42 timeout 3 break
43 "asswd" break
44 }
45 exit
46 wantterm:
47 send "vt100"
48 exit
49 screengeom:
50 send "stty rows $(TERMLIN) columns 80"
51 # If you use a display mode with some other width than 80 columns,
52 # you may want to use the following format.
53 #send "stty rows $(TERMLIN) columns $(COLUMNS)"
54 exit
55 failed1:
56 print \nLogin Failed (wrong password?)
57 exit