|
Packit |
15a96c |
# Generic UNIX login script.
|
|
Packit |
15a96c |
# Can be used to automatically login to almost every UNIX box.
|
|
Packit |
15a96c |
#
|
|
Packit |
15a96c |
# Some variables.
|
|
Packit |
15a96c |
set a 0
|
|
Packit |
15a96c |
set b a
|
|
Packit |
15a96c |
print Trying to Login..
|
|
Packit |
15a96c |
# Skip initial 'send ""', it seems to matter sometimes..
|
|
Packit |
15a96c |
goto skip
|
|
Packit |
15a96c |
loop1:
|
|
Packit |
15a96c |
# Send loginname not more than three times.
|
|
Packit |
15a96c |
send ""
|
|
Packit |
15a96c |
inc a
|
|
Packit |
15a96c |
skip:
|
|
Packit |
15a96c |
if a > 3 goto failed1
|
|
Packit |
15a96c |
expect {
|
|
Packit |
15a96c |
"ogin:"
|
|
Packit |
15a96c |
"assword:" send ""
|
|
Packit |
15a96c |
"NO CARRIER" exit
|
|
Packit |
15a96c |
timeout 60 goto loop1
|
|
Packit |
15a96c |
}
|
|
Packit |
15a96c |
loop2:
|
|
Packit |
15a96c |
send "$(LOGIN)"
|
|
Packit |
15a96c |
|
|
Packit |
15a96c |
# Send password not more than three times.
|
|
Packit |
15a96c |
inc b
|
|
Packit |
15a96c |
if b > 3 goto failed1
|
|
Packit |
15a96c |
expect {
|
|
Packit |
15a96c |
"assword:"
|
|
Packit |
15a96c |
"ogin:" goto loop2
|
|
Packit |
15a96c |
timeout 60 goto loop2
|
|
Packit |
15a96c |
}
|
|
Packit |
15a96c |
send "$(PASS)"
|
|
Packit |
15a96c |
# If we don't get "incorrect" within 3 seconds, it's probably OK.
|
|
Packit |
15a96c |
# If they ask for a terminal, we are logged in. Tell them we're
|
|
Packit |
15a96c |
# using vt100.
|
|
Packit |
15a96c |
# If we get the bash prompt, send them the screen geometry.
|
|
Packit |
15a96c |
expect {
|
|
Packit |
15a96c |
"TERM=" goto wantterm
|
|
Packit |
15a96c |
"incorrect" goto loop1
|
|
Packit |
15a96c |
"bash$" goto screengeom
|
|
Packit |
15a96c |
timeout 3 break
|
|
Packit |
15a96c |
"asswd" break
|
|
Packit |
15a96c |
}
|
|
Packit |
15a96c |
exit
|
|
Packit |
15a96c |
wantterm:
|
|
Packit |
15a96c |
send "vt100"
|
|
Packit |
15a96c |
exit
|
|
Packit |
15a96c |
screengeom:
|
|
Packit |
15a96c |
send "stty rows $(TERMLIN) columns 80"
|
|
Packit |
15a96c |
# If you use a display mode with some other width than 80 columns,
|
|
Packit |
15a96c |
# you may want to use the following format.
|
|
Packit |
15a96c |
#send "stty rows $(TERMLIN) columns $(COLUMNS)"
|
|
Packit |
15a96c |
exit
|
|
Packit |
15a96c |
failed1:
|
|
Packit |
15a96c |
print \nLogin Failed (wrong password?)
|
|
Packit |
15a96c |
exit
|