;set verbose
;set debug stdout
set log -n %1%2.log
show on 
show version
expect -r "UNIT RPA. WENT OFF-LINE" ; exit 1
expect "^Q" exit 1
set fha disable
set dpa disable
set dpb disable
set tua disable
set rpa disable
set rpb disable
set mta enable
set env C=%1
set env CPU=KA
set env DISK=%2
set env TAPE=mta0
set env TAPEB=mta0
set env VM=no
set env M=monka
set cpu 256k idle
set mta type=b
if "%DISK%" == "rp" set env TAPE=tua0 ; set env TAPEB=mta0; set rpa enable ; set rpb enable ; set tua enable ; set env T=/tm03
if "%DISK%" == "dp" set dpa enable ; set env T=
if -i "%C%" == "ki" set env CPU=KI ; set env M=monki ; set cpu 512k
if -i "%C%" == "kv" set env CPU=KI ; set env M=monki ; set cpu 512k ; set env VM=yes
if -i "%C%" == "kl" set env CPU=KL ; set env TAPEB=mta0 ; set env M=monkl ; set env VM=yes; set cty rsx10 ; set cpu 512k 
if "%DISK%" == "dp" at -n dpa0 dsk/%C%_dskb0.rp3
if "%DISK%" == "dp" at -n dpa1 dsk/%C%_dskb1.rp3
if "%DISK%" == "dp" at -n dpa2 dsk/%C%_dskb2.rp3
if "%DISK%" == "dp" at -n dpa3 dsk/%C%_dskb3.rp3
if "%DISK%" == "rp" at -n rpa0 dsk/%C%_dskb0.rp6
if "%DISK%" == "rp" at -n rpa1 dsk/%C%_dskb1.rp6
at -r %TAPEB% tapes/mon.tap
if "%TAPEB%" == "mta0" 'expect "BTM>" send -t after=1000k  "%M%[1,4]\r" ; continue'
if "%TAPEB%" == "tua0" 'expect "BTM>" send -t after=1000k  "%M%[1,4]/TM03\r" ; continue'
expect "RELOAD:" send -t after=100k  "hard\r"; continue
expect "DATE:" send -t after=100k  "04-21-78\r"; continue
expect "TIME:" send -t after=100k  "1000\r"; continue
expect "STARTUP OPTION:" send -t after=100k  "refresh\r"; continue
do refresh.do
expect "STARTUP OPTION:" send -t after=100k "quick\r"; continue
; Restore base system.
do  initload.do
expect "\n\n." send "LOGIN 1,2\r"; continue
expect "Password:" send "FAILSA\r"; continue
; Install disk boot blocks.
if "%CPU%" == "KA" 'expect "\r\n." send "RUN WABOOT[10,7]\r"; continue'
if "%CPU%" == "KI" 'expect "\r\n." send "RUN WIBOOT[10,7]\r"; continue'
if "%CPU%" == "KL" 'expect "\r\n." send "RUN WLBOOT[10,7]\r"; continue'
expect "SELECT UNITS?" send "NO\r"; continue
; Copy new system down.
expect "\r\n." send "COPY UNV:<155>=[10,7]UUOSYM.UNV\r"; continue
expect "\r\n." send "COPY SYS:<155>=[10,7]SYSTEM.*\r"; continue
expect "\r\n." send "KJOB/F\r"; continue
; Switch to new system.
if "%TAPE%" == "mta0" 'expect "\n\n." set cty stop ; continue'
if "%TAPE%" == "tua0" 'expect "\n\n." set cty stop ; det mta ; set mta disable ; continue'
expect "\r\nBOOTS\r\n\r\n" send -t after=1000 delay=2000 "system\r"; continue
expect "?J" send -t delay=2000 "system\r"; continue
expect "RELOAD:" send  "hard\r"; noexpect "?J"; continue
expect "DATE:" send  "04-21-78\r"; continue
expect "TIME:" send  "1100\r"; continue
expect "STARTUP OPTION:" send  "no ini\r"; continue
expect "\r\n." send "set tty lc\r"; continue
expect "\r\n." send "login 10,6\r"; continue
expect -ri "Password:" send "dist\r"; continue
do customize.do
expect "\n\n." send "login 10,6\r"; continue
expect -ri "Password:" send "dist\r"; continue
do apl.do
do fortran.do
do f40.do
do algol.do
do basic.do
do cobol.do
do bcpl.do
do dbms.do
do mcs.do
do sort.do
do kermit.do
expect "\r\n." send "k/f\r"; continue
expect "\n\n." send "login 1,2\r"; continue
expect -ri "Password:" send "FAILSA\r"; continue
if "%CPU%" == "KL" set env CPU=KI
expect "\r\n." send "COPY SYS:<155>=[10,6,ALG10A]*.EXE\r"; continue
expect "\r\n." send "COPY HLP:<155>=[10,6,ALG10A]*.HLP\r"; continue
expect "\r\n." send "COPY SYS:<155>=[10,6,ALG10A]ALGLIB.REL\r"; continue
expect "\r\n." send "COPY SYS:<155>=[10,6,FTN5A]FORT??.EXE\r"; continue
expect "\r\n." send "COPY HLP:<155>=[10,6,FTN5A]*.HLP\r"; continue
expect "\r\n." send "COPY SYS:FORLIB.REL<155>=[10,6,FTN5A]FORL%CPU%.REL\r"; continue
expect "\r\n." send "COPY SYS:<155>=[10,6,FTN5A]FORO%CPU%.EXE\r"; continue
expect "\r\n." send "REN  SYS:FOROTS.EXE=SYS:FORO%CPU%.EXE\r"; continue
expect "\r\n." send "COPY UNV:<155>=[10,6,FTN5A]F%CPU%???.UNV\r"; continue
expect "\r\n." send "COPY SYS:<155>=[10,6,F40]*.EXE\r"; continue
expect "\r\n." send "COPY REL:<155>=[10,6,F40]*.REL\r"; continue
expect "\r\n." send "COPY SYS:<155>=[10,6,APLSF]*.EXE\r"; continue
expect "\r\n." send "COPY HLP:<155>=[10,6,APLSF]*.HLP\r"; continue
expect "\r\n." send "COPY SYS:<155>=[10,6,APLSF]*.EXE\r"; continue
expect "\r\n." send "COPY SYS:<155>=[10,6,BAS17F]*.EXE\r"; continue
expect "\r\n." send "COPY HLP:<155>=[10,6,BAS17F]*.HLP\r"; continue
expect "\r\n." send "COPY HLP:<155>=[10,6,COB12A]*.HLP\r"; continue
expect "\r\n." send "COPY SYS:<155>=[10,6,COB12A]*.EXE,COBDDT.REL,LIBOL.REL\r"; continue
expect "\r\n." send "COPY UNV:<155>=[10,6,COB12A]*.UNV\r"; continue
expect "\r\n." send "COPY HLP:<155>=[10,6,DBMSV5]*.HLP\r"; continue
expect "\r\n." send "COPY SYS:<155>=[10,6,DBMSV5]*.EXE\r"; continue
expect "\r\n." send "COPY REL:<155>=[10,6,SORT]FORLIB.REL,LIBOL.REL\r"; continue
expect "\r\n." send "COPY SYS:<155>=[10,6,BCPL]*.EXE\r"; continue
expect "\r\n." send "COPY SYS:<155>=[10,6,BCPL]BCPLIB.REL\r"; continue
expect "\r\n." send "COPY BCL:<155>=[10,6,BCPL]*.GET\r"; continue
expect "\r\n." send "COPY SYS:<155>=[10,6,KERMIT]KERMIT.EXE\r"; continue
expect "\r\n." send "COPY HLP:<155>=[10,6,KERMIT]KERMIT.HLP,[10,6,KERMIT]KERMIT.H5\r"; continue
; Update SCDSET to remove error messages.
expect "\r\n." send "r scdset\r"; continue
expect "WHICH FUNCTION DO YOU WANT "  send "EDIT\r"; continue
expect "WHAT FUNCTION" send "WRITE\r"; continue
expect "WHICH MAP (" send "0\r"; continue
expect "\r\n*" send "DSK:SCDMAP.SYS[1,4]/ACCESS=SEQOUT/MODE=DUMP\033" ; continue
expect "WHAT FUNCTION" send "EXIT\r"; continue
expect "WHICH FUNCTION DO YOU WANT "  send "EXIT\r"; continue
; Allow 1,2 to log in on dataset/remote lines.
expect "\r\n." send "R REACT\r" ; continue
expect "\r\n*" send "R\r"; continue
expect "\r\n*" send "C 1,2\r"; continue
expect "CHANGE:" send "LOG\r"; continue
expect "ARGS:" send "ALL\r"; continue
expect "CHANGE:" send "\r"; continue
expect "\r\n*" send "C 10,6\r"; continue
expect "CHANGE:" send "LOG\r"; continue
expect "ARGS:" send "ALL\r"; continue
expect "CHANGE:" send "\r"; continue
expect "\r\n*" send "C 10,7\r"; continue
expect "CHANGE:" send "LOG\r"; continue
expect "ARGS:" send "ALL\r"; continue
expect "CHANGE:" send "\r"; continue
expect "\r\n*" send "W\r"; continue
; Give 100,100 more quota.
expect "\r\n*" send "A\r"; continue
expect "\r\n*" send "C 100,100\r"; continue
expect "CHANGE:" send "FCF\r"; continue
expect "ARGS:" send "DSKB\r"; 'expect "\r\n" send "100000\r"; continue'; continue
expect "CHANGE:" send "OUT\r"; continue
expect "ARGS:" send "DSKB\r"; 'expect "\r\n" send "100000\r"; continue'; continue
expect "CHANGE:" send "\r"; continue
expect "\r\n*" send "C 10,777777\r"; continue
expect "CHANGE:" send "FCF\r"; continue
expect "ARGS:" send "DSKB\r"; 'expect "\r\n" send "200000\r"; continue'; continue
expect "CHANGE:" send "OUT\r"; continue
expect "ARGS:" send "DSKB\r"; 'expect "\r\n" send "200000\r"; continue'; continue
expect "CHANGE:" send "\r"; continue
expect "\r\n*" send "W\r"; continue
expect "\r\n*" send "E\r"; continue
expect "\r\n." send "K/F\r"; continue
expect "\n\n." send "login 10,6\r"; continue
expect -ri "Password:" send "dist\r"; continue
do bcpl_build.do
do iql.do
if "%CPU%" == "KA" 'do focal.do'
do ssp.do
if "%VM%" == "yes" 'do galaxy.do'
expect "\r\n." send "k/f\r"; continue
expect "\n\n." send "login 1,2\r"; continue
expect -ri "Password:" send "FAILSA\r"; continue
if "%VM%" == "no" goto NOGAL
expect "\r\n." send "COPY SYS:<155>=[10,6,GAL2]*.EXE\r"; continue
expect "\r\n." send "DEL SYS:GALGEN.EXE\r"; continue
expect "\r\n." send "MAKE SYS:LPFORM.INI\r"; continue
if "%CPU%" == "KL" 'expect "\r\n." send "COPY SYS:=[10,7]NORMAL.VFU\r"; continue'
expect "\r\n*" send "I\r\033EX\033\033"; continue
expect "\r\n." send "MAKE SYS:OPR.ATO\r"; continue
expect "\r\n*" send "I:TLOG\r:SLOGIN 1/2\r:SILENCE\r:DEFINE D=\rD-R DAEMON\r:REVIVE\r\033\033"; continue
expect "\r\n*" send "I:SLOGIN 1/2\r:SILENCE\r:DEFINE S=\rS-R OPR\rS-WATCH\r:REVIVE\r\033\033"; continue
expect "\r\n*" send "I:SLOGIN 1/2\r:SILENCE\r:DEFINE Q=\rQ-R QUASAR\r:REVIVE\r\033\033"; continue
expect "\r\n*" send "I:SLOGIN 1/2\r:SILENCE\r:DEFINE B=\rB-R BATCON\r:REVIVE\rB-START\r\033\033"; continue
expect "\r\n*" send "I:SLOGIN 1/2\r:SILENCE\r:DEFINE SI=\rSI-R SPRINT\r:REVIVE\r\033\033"; continue
expect "\r\n*" send "I:SLOGIN 1/2\r:SILENCE\r:DEFINE L=\rL-R LPTSPL\r:REVIVE\rL-START\r\033\033"; continue
expect "\r\n*" send "EX\033\033"; continue
:NOGAL
expect "\r\n." send "COPY SYS:<155>=[10,6,IQLV30]*.EXE\r"; continue
expect "\r\n." send "COPY HLP:<155>=[10,6,IQLV30]*.HLP\r"; continue
expect "\r\n." send "COPY REL:<155>=[10,6,IQLV30]*.REL\r"; continue
expect "\r\n." send "COPY SYS:<155>=[10,6,MCS10]MCS???.EXE\r"; continue
expect "\r\n." send "COPY HLP:<155>=[10,6,MCS10]*.HLP\r"; continue
if "%CPU%" == "KA" 'expect "\r\n." send "COPY SYS:<155>=[10,6,FOCAL]FOCAL.EXE\r"; continue'
expect "\r\n." send "COPY REL:<155>=[10,6,SSP]SSP.REL\r"; continue
expect "\r\n." send "COPY SYS:<155>=[10,6,BCPL]BCPLIB.REL\r"; continue
expect "\r\n." send "COPY DSKB:[1,2]=SYS:SYSTEM.EXE\r"; continue
expect "\r\n." send "k/f\r"; continue
do games.do
do test.do
expect "\n\n." send "login 1,2\r"; continue
expect -ri "Password:" send "FAILSA\r"; continue
expect "\r\n." send "COPY SYS:<155>=[10,6,GAMES]ADVENT.EXE\r"; continue
expect "\r\n." send "COPY SYS:<155>=[10,6,GAMES]MONOP.EXE\r"; continue
expect "\r\n." send "ASSIGN MTA0 BACKUP\r"; at %TAPE% -n tapes/%C%%DISK%_system.tap; continue
expect "\r\n." send "SET DEN MTA0 800\r"; continue
expect "\r\n." send "SET BLOCKSIZE MTA0 2000\r"; continue
expect "\r\n." send "COPY MTA0:=DSKB:[10,7]BOOTM.REL\r"; continue
expect "\r\n." send "SET BLOCKSIZE MTA0 128\r"; continue
expect "\r\n." send "COPY MTA0:=DSKB:[1,4]BACKUP.EXE\r"; continue
expect "\r\n." send "R BACKUP\r"; continue
expect "\r\n/" send "DEN 800\r"; continue
expect "\r\n/" send "SAVE DSKB:=DSKB:\r"; continue
expect "\r\n/" send "REWIND\r"; continue
expect "\r\n/" send "SKIP 2\r"; continue
expect "\r\n/" send "FILES\r"; continue
expect "\r\n/" send "PRINT TTY:\r"; continue
expect "\r\n/" send "REWIND\r"; continue
expect "\r\n/" send "EXIT\r"; continue
expect "\r\n." send "k/f\r"; continue
expect "\n\n." set cty stop; continue
expect "?LOGIN please" set cty stop; continue
expect "\r\nBOOTS\r\n\r\n" quit
boot  %TAPEB%
