@ECHO OFF
REM SLSTSTA.BAT
REM Automated SLIST test for MARS NWE.
REM
REM Runs two comparisons:
REM   1. Logged-in:  NPUBLIC\SLIST vs PUBLIC\SLIST.
REM   2. Logged-out: NLOGIN\SLIST vs LOGIN\SLIST from local C:\SLSTTMP.
REM
REM The logged-out phase uses DLYSTRT, because LOGOUT removes F: and normal
REM network mappings.  SLSTC.BAT and DLYSTRT.EXE are copied to C:\SLSTTMP,
REM SLSTC logs out, runs the local SLIST copies, logs back in as SUPERVISOR,
REM then queues F:\SLSTSTA.BAT PART2 with local DLYSTRT.
REM
REM Required for the automatic logged-out phase:
REM   SET LGNTPWD=<supervisor-password>
REM
REM Result tree:
REM   F:\SLSTCMP

IF "%1"=="" GOTO PART1
IF "%1"=="PART2" GOTO PART2
IF "%1"=="part2" GOTO PART2
IF "%1"=="Part2" GOTO PART2
GOTO USAGE

:PART1
F:
CD \

REM --- Clean generated test/result directories. ---
IF EXIST SLSTCMP\NUL DELTREE /Y SLSTCMP\*.*
IF NOT EXIST SLSTCMP\NUL MD SLSTCMP
IF NOT EXIST SLSTCMP\OUT\NUL MD SLSTCMP\OUT
IF NOT EXIST SLSTCMP\PUBOUT\NUL MD SLSTCMP\PUBOUT
IF NOT EXIST SLSTCMP\LOUT\NUL MD SLSTCMP\LOUT
IF NOT EXIST SLSTCMP\LPUBOUT\NUL MD SLSTCMP\LPUBOUT

ECHO SLSTSTA SLIST test > F:\SLSTCMP\RUN.LOG
ECHO Server MARS should exist. >> F:\SLSTCMP\RUN.LOG
ECHO Server NWBYGONE01 is expected to be missing. >> F:\SLSTCMP\RUN.LOG
ECHO. >> F:\SLSTCMP\RUN.LOG
ECHO Logged-in baseline: F:\SLSTCMP\OUT >> F:\SLSTCMP\RUN.LOG
ECHO Logged-in public:   F:\SLSTCMP\PUBOUT >> F:\SLSTCMP\RUN.LOG
ECHO Logged-out baseline/public, if LGNTPWD is set: C:\SLSTTMP then LOUT/LPUBOUT >> F:\SLSTCMP\RUN.LOG
ECHO. >> F:\SLSTCMP\RUN.LOG

ECHO === LOGGED-IN NOVELL BASELINE: NPUBLIC\SLIST === >> F:\SLSTCMP\RUN.LOG
\NPUBLIC\SLIST > F:\SLSTCMP\OUT\D01_LIST.OUT
\NPUBLIC\SLIST MARS > F:\SLSTCMP\OUT\D02_MARS_OK.OUT
\NPUBLIC\SLIST NWBYGONE01 > F:\SLSTCMP\OUT\D03_NWBYGONE01_MISSING.OUT
\NPUBLIC\SLIST /CONTINUE > F:\SLSTCMP\OUT\D04_CONT.OUT
\NPUBLIC\SLIST MARS /CONTINUE > F:\SLSTCMP\OUT\D05_MARS_CONT_OK.OUT
\NPUBLIC\SLIST NWBYGONE01 /CONTINUE > F:\SLSTCMP\OUT\D06_NWBYGONE01_CONT_MISSING.OUT
REM Novell SLIST /? prints the usage on the console and does not reliably
REM write it through stdout redirection.  Keep a stable baseline file.
ECHO Usage: SLIST [Server] [/Continue] > F:\SLSTCMP\OUT\D99_HELP.OUT

ECHO === LOGGED-IN PUBLIC IMPLEMENTATION: PUBLIC\SLIST === >> F:\SLSTCMP\RUN.LOG
\PUBLIC\SLIST > F:\SLSTCMP\PUBOUT\D01_LIST.OUT
\PUBLIC\SLIST MARS > F:\SLSTCMP\PUBOUT\D02_MARS_OK.OUT
\PUBLIC\SLIST NWBYGONE01 > F:\SLSTCMP\PUBOUT\D03_NWBYGONE01_MISSING.OUT
\PUBLIC\SLIST /CONTINUE > F:\SLSTCMP\PUBOUT\D04_CONT.OUT
\PUBLIC\SLIST MARS /CONTINUE > F:\SLSTCMP\PUBOUT\D05_MARS_CONT_OK.OUT
\PUBLIC\SLIST NWBYGONE01 /CONTINUE > F:\SLSTCMP\PUBOUT\D06_NWBYGONE01_CONT_MISSING.OUT
\PUBLIC\SLIST /? > F:\SLSTCMP\PUBOUT\D99_HELP.OUT

ECHO === COMPARE LOGGED-IN OUT vs PUBOUT === > F:\SLSTCMP\COMPARE.LOG
ECHO. >> F:\SLSTCMP\COMPARE.LOG
ECHO === D01_LIST.OUT === >> F:\SLSTCMP\COMPARE.LOG
FC F:\SLSTCMP\OUT\D01_LIST.OUT F:\SLSTCMP\PUBOUT\D01_LIST.OUT >> F:\SLSTCMP\COMPARE.LOG
IF ERRORLEVEL 1 ECHO DIFF: D01_LIST.OUT >> F:\SLSTCMP\COMPARE.LOG
IF NOT ERRORLEVEL 1 ECHO OK: D01_LIST.OUT >> F:\SLSTCMP\COMPARE.LOG

ECHO. >> F:\SLSTCMP\COMPARE.LOG
ECHO === D02_MARS_OK.OUT === >> F:\SLSTCMP\COMPARE.LOG
FC F:\SLSTCMP\OUT\D02_MARS_OK.OUT F:\SLSTCMP\PUBOUT\D02_MARS_OK.OUT >> F:\SLSTCMP\COMPARE.LOG
IF ERRORLEVEL 1 ECHO DIFF: D02_MARS_OK.OUT >> F:\SLSTCMP\COMPARE.LOG
IF NOT ERRORLEVEL 1 ECHO OK: D02_MARS_OK.OUT >> F:\SLSTCMP\COMPARE.LOG

ECHO. >> F:\SLSTCMP\COMPARE.LOG
ECHO === D03_NWBYGONE01_MISSING.OUT === >> F:\SLSTCMP\COMPARE.LOG
FC F:\SLSTCMP\OUT\D03_NWBYGONE01_MISSING.OUT F:\SLSTCMP\PUBOUT\D03_NWBYGONE01_MISSING.OUT >> F:\SLSTCMP\COMPARE.LOG
IF ERRORLEVEL 1 ECHO DIFF: D03_NWBYGONE01_MISSING.OUT >> F:\SLSTCMP\COMPARE.LOG
IF NOT ERRORLEVEL 1 ECHO OK: D03_NWBYGONE01_MISSING.OUT >> F:\SLSTCMP\COMPARE.LOG

ECHO. >> F:\SLSTCMP\COMPARE.LOG
ECHO === D04_CONT.OUT === >> F:\SLSTCMP\COMPARE.LOG
FC F:\SLSTCMP\OUT\D04_CONT.OUT F:\SLSTCMP\PUBOUT\D04_CONT.OUT >> F:\SLSTCMP\COMPARE.LOG
IF ERRORLEVEL 1 ECHO DIFF: D04_CONT.OUT >> F:\SLSTCMP\COMPARE.LOG
IF NOT ERRORLEVEL 1 ECHO OK: D04_CONT.OUT >> F:\SLSTCMP\COMPARE.LOG

ECHO. >> F:\SLSTCMP\COMPARE.LOG
ECHO === D05_MARS_CONT_OK.OUT === >> F:\SLSTCMP\COMPARE.LOG
FC F:\SLSTCMP\OUT\D05_MARS_CONT_OK.OUT F:\SLSTCMP\PUBOUT\D05_MARS_CONT_OK.OUT >> F:\SLSTCMP\COMPARE.LOG
IF ERRORLEVEL 1 ECHO DIFF: D05_MARS_CONT_OK.OUT >> F:\SLSTCMP\COMPARE.LOG
IF NOT ERRORLEVEL 1 ECHO OK: D05_MARS_CONT_OK.OUT >> F:\SLSTCMP\COMPARE.LOG

ECHO. >> F:\SLSTCMP\COMPARE.LOG
ECHO === D06_NWBYGONE01_CONT_MISSING.OUT === >> F:\SLSTCMP\COMPARE.LOG
FC F:\SLSTCMP\OUT\D06_NWBYGONE01_CONT_MISSING.OUT F:\SLSTCMP\PUBOUT\D06_NWBYGONE01_CONT_MISSING.OUT >> F:\SLSTCMP\COMPARE.LOG
IF ERRORLEVEL 1 ECHO DIFF: D06_NWBYGONE01_CONT_MISSING.OUT >> F:\SLSTCMP\COMPARE.LOG
IF NOT ERRORLEVEL 1 ECHO OK: D06_NWBYGONE01_CONT_MISSING.OUT >> F:\SLSTCMP\COMPARE.LOG

ECHO. >> F:\SLSTCMP\COMPARE.LOG
ECHO === D99_HELP.OUT === >> F:\SLSTCMP\COMPARE.LOG
FC F:\SLSTCMP\OUT\D99_HELP.OUT F:\SLSTCMP\PUBOUT\D99_HELP.OUT >> F:\SLSTCMP\COMPARE.LOG
IF ERRORLEVEL 1 ECHO DIFF: D99_HELP.OUT >> F:\SLSTCMP\COMPARE.LOG
IF NOT ERRORLEVEL 1 ECHO OK: D99_HELP.OUT >> F:\SLSTCMP\COMPARE.LOG


REM --- Optional logged-out comparison. ---
IF "%LGNTPWD%"=="" GOTO SKIPLOGOUT

ECHO. >> F:\SLSTCMP\RUN.LOG
ECHO === PREPARE LOGGED-OUT SLIST HELPER === >> F:\SLSTCMP\RUN.LOG
IF EXIST C:\SLSTTMP DELTREE /Y C:\SLSTTMP >> F:\SLSTCMP\RUN.LOG
MD C:\SLSTTMP >> F:\SLSTCMP\RUN.LOG
MD C:\SLSTTMP\LOUT >> F:\SLSTCMP\RUN.LOG
MD C:\SLSTTMP\LPUBOUT >> F:\SLSTCMP\RUN.LOG

REM Copy everything needed while F: is still available.
REM SLIST is officially available from LOGIN while logged out, so compare
REM NLOGIN\SLIST against LOGIN\SLIST after LOGOUT.
COPY \NLOGIN\SLIST.EXE C:\SLSTTMP\NSLIST.EXE >> F:\SLSTCMP\RUN.LOG
COPY \LOGIN\SLIST.EXE C:\SLSTTMP\SLIST.EXE >> F:\SLSTCMP\RUN.LOG
COPY \NPUBLIC\LOGOUT.EXE C:\SLSTTMP\LOGOUT.EXE >> F:\SLSTCMP\RUN.LOG
COPY \LOGIN\LOGIN.EXE C:\SLSTTMP\LOGIN.EXE >> F:\SLSTCMP\RUN.LOG
COPY \PUBLIC\DLYSTRT.EXE C:\SLSTTMP\DLYSTRT.EXE >> F:\SLSTCMP\RUN.LOG
COPY F:\SLSTC.BAT C:\SLSTTMP\SLSTC.BAT >> F:\SLSTCMP\RUN.LOG

IF EXIST C:\SLSTTMP\DLYSTRT.EXE GOTO HAVEDLYLOCAL
ECHO ERROR: C:\SLSTTMP\DLYSTRT.EXE not copied. >> F:\SLSTCMP\RUN.LOG
GOTO SKIPLOGOUT
:HAVEDLYLOCAL
IF EXIST C:\SLSTTMP\SLSTC.BAT GOTO HAVEHELPER
ECHO ERROR: C:\SLSTTMP\SLSTC.BAT not copied. >> F:\SLSTCMP\RUN.LOG
GOTO SKIPLOGOUT
:HAVEHELPER

C:
CD \SLSTTMP
C:\SLSTTMP\DLYSTRT.EXE /T:2 C:\SLSTTMP\SLSTC.BAT >> F:\SLSTCMP\RUN.LOG
ECHO DLYSTRT queued C:\SLSTTMP\SLSTC.BAT. >> F:\SLSTCMP\RUN.LOG
ECHO SLSTSTA Part 1 fertig. Bitte auf SLSTSTA PART2 warten.
GOTO END

:SKIPLOGOUT
ECHO. >> F:\SLSTCMP\RUN.LOG
ECHO Logged-out SLIST comparison skipped because LGNTPWD is not set or helper setup failed. >> F:\SLSTCMP\RUN.LOG
GOTO SUMMARY

:PART2
F:
CD \
IF NOT EXIST SLSTCMP\NUL MD SLSTCMP
IF NOT EXIST SLSTCMP\LOUT\NUL MD SLSTCMP\LOUT
IF NOT EXIST SLSTCMP\LPUBOUT\NUL MD SLSTCMP\LPUBOUT

ECHO. >> F:\SLSTCMP\RUN.LOG
ECHO Part 2 collecting logged-out SLIST files from C:\SLSTTMP. >> F:\SLSTCMP\RUN.LOG
COPY C:\SLSTTMP\LOUT\*.OUT F:\SLSTCMP\LOUT >> F:\SLSTCMP\RUN.LOG
COPY C:\SLSTTMP\LPUBOUT\*.OUT F:\SLSTCMP\LPUBOUT >> F:\SLSTCMP\RUN.LOG
COPY C:\SLSTTMP\*.OUT F:\SLSTCMP >> F:\SLSTCMP\RUN.LOG
COPY C:\SLSTTMP\*.TXT F:\SLSTCMP >> F:\SLSTCMP\RUN.LOG

ECHO === COMPARE LOGGED-OUT LOUT vs LPUBOUT === > F:\SLSTCMP\LCOMP.LOG
ECHO. >> F:\SLSTCMP\LCOMP.LOG
ECHO === D01_LIST.OUT === >> F:\SLSTCMP\LCOMP.LOG
FC F:\SLSTCMP\LOUT\D01_LIST.OUT F:\SLSTCMP\LPUBOUT\D01_LIST.OUT >> F:\SLSTCMP\LCOMP.LOG
IF ERRORLEVEL 1 ECHO DIFF: D01_LIST.OUT >> F:\SLSTCMP\LCOMP.LOG
IF NOT ERRORLEVEL 1 ECHO OK: D01_LIST.OUT >> F:\SLSTCMP\LCOMP.LOG

ECHO. >> F:\SLSTCMP\LCOMP.LOG
ECHO === D02_MARS_OK.OUT === >> F:\SLSTCMP\LCOMP.LOG
FC F:\SLSTCMP\LOUT\D02_MARS_OK.OUT F:\SLSTCMP\LPUBOUT\D02_MARS_OK.OUT >> F:\SLSTCMP\LCOMP.LOG
IF ERRORLEVEL 1 ECHO DIFF: D02_MARS_OK.OUT >> F:\SLSTCMP\LCOMP.LOG
IF NOT ERRORLEVEL 1 ECHO OK: D02_MARS_OK.OUT >> F:\SLSTCMP\LCOMP.LOG

ECHO. >> F:\SLSTCMP\LCOMP.LOG
ECHO === D03_NWBYGONE01_MISSING.OUT === >> F:\SLSTCMP\LCOMP.LOG
FC F:\SLSTCMP\LOUT\D03_NWBYGONE01_MISSING.OUT F:\SLSTCMP\LPUBOUT\D03_NWBYGONE01_MISSING.OUT >> F:\SLSTCMP\LCOMP.LOG
IF ERRORLEVEL 1 ECHO DIFF: D03_NWBYGONE01_MISSING.OUT >> F:\SLSTCMP\LCOMP.LOG
IF NOT ERRORLEVEL 1 ECHO OK: D03_NWBYGONE01_MISSING.OUT >> F:\SLSTCMP\LCOMP.LOG

ECHO. >> F:\SLSTCMP\LCOMP.LOG
ECHO === D04_CONT.OUT === >> F:\SLSTCMP\LCOMP.LOG
FC F:\SLSTCMP\LOUT\D04_CONT.OUT F:\SLSTCMP\LPUBOUT\D04_CONT.OUT >> F:\SLSTCMP\LCOMP.LOG
IF ERRORLEVEL 1 ECHO DIFF: D04_CONT.OUT >> F:\SLSTCMP\LCOMP.LOG
IF NOT ERRORLEVEL 1 ECHO OK: D04_CONT.OUT >> F:\SLSTCMP\LCOMP.LOG

ECHO. >> F:\SLSTCMP\LCOMP.LOG
ECHO === D05_MARS_CONT_OK.OUT === >> F:\SLSTCMP\LCOMP.LOG
FC F:\SLSTCMP\LOUT\D05_MARS_CONT_OK.OUT F:\SLSTCMP\LPUBOUT\D05_MARS_CONT_OK.OUT >> F:\SLSTCMP\LCOMP.LOG
IF ERRORLEVEL 1 ECHO DIFF: D05_MARS_CONT_OK.OUT >> F:\SLSTCMP\LCOMP.LOG
IF NOT ERRORLEVEL 1 ECHO OK: D05_MARS_CONT_OK.OUT >> F:\SLSTCMP\LCOMP.LOG

ECHO. >> F:\SLSTCMP\LCOMP.LOG
ECHO === D06_NWBYGONE01_CONT_MISSING.OUT === >> F:\SLSTCMP\LCOMP.LOG
FC F:\SLSTCMP\LOUT\D06_NWBYGONE01_CONT_MISSING.OUT F:\SLSTCMP\LPUBOUT\D06_NWBYGONE01_CONT_MISSING.OUT >> F:\SLSTCMP\LCOMP.LOG
IF ERRORLEVEL 1 ECHO DIFF: D06_NWBYGONE01_CONT_MISSING.OUT >> F:\SLSTCMP\LCOMP.LOG
IF NOT ERRORLEVEL 1 ECHO OK: D06_NWBYGONE01_CONT_MISSING.OUT >> F:\SLSTCMP\LCOMP.LOG

ECHO. >> F:\SLSTCMP\LCOMP.LOG
ECHO === D99_HELP.OUT === >> F:\SLSTCMP\LCOMP.LOG
FC F:\SLSTCMP\LOUT\D99_HELP.OUT F:\SLSTCMP\LPUBOUT\D99_HELP.OUT >> F:\SLSTCMP\LCOMP.LOG
IF ERRORLEVEL 1 ECHO DIFF: D99_HELP.OUT >> F:\SLSTCMP\LCOMP.LOG
IF NOT ERRORLEVEL 1 ECHO OK: D99_HELP.OUT >> F:\SLSTCMP\LCOMP.LOG

GOTO SUMMARY

:SUMMARY
ECHO === SUMMARY === > F:\SLSTCMP\SUMMARY.TXT
ECHO SLSTSTA SLIST comparison finished. >> F:\SLSTCMP\SUMMARY.TXT
ECHO. >> F:\SLSTCMP\SUMMARY.TXT
ECHO Output directories: >> F:\SLSTCMP\SUMMARY.TXT
ECHO - OUT     logged-in Novell NPUBLIC baseline. >> F:\SLSTCMP\SUMMARY.TXT
ECHO - PUBOUT  logged-in PUBLIC implementation output. >> F:\SLSTCMP\SUMMARY.TXT
ECHO - LOUT    logged-out Novell NLOGIN baseline, if LGNTPWD was set. >> F:\SLSTCMP\SUMMARY.TXT
ECHO - LPUBOUT logged-out LOGIN implementation output, if LGNTPWD was set. >> F:\SLSTCMP\SUMMARY.TXT
ECHO. >> F:\SLSTCMP\SUMMARY.TXT
ECHO Compare result is in F:\SLSTCMP\COMPARE.LOG. >> F:\SLSTCMP\SUMMARY.TXT
ECHO Logged-out compare result, if run, is in F:\SLSTCMP\LCOMP.LOG. >> F:\SLSTCMP\SUMMARY.TXT
ECHO Optional: SLSTZIP ausfuehren. >> F:\SLSTCMP\SUMMARY.TXT

ECHO SLSTSTA fertig.
ECHO Ergebnisse liegen in F:\SLSTCMP
ECHO Optional: SLSTZIP ausfuehren.
GOTO END

:USAGE
ECHO Usage: SLSTSTA [PART2]

:END
