@ECHO OFF

REM NCPTSTA.BAT

REM Automated Novell-vs-PUBLIC NCOPY comparison for MARS NWE.

REM

REM OUT/POSTNOV = Novell reference using NPUBLIC\NCOPY and NPUBLIC readback tools.

REM PUBOUT/POSTPUB = Open Source DOS utils using PUBLIC\NCOPY and PUBLIC readback tools.

REM COMPARE.LOG compares command output and resulting file state.



F:

CD \

REM --- Dispatch subcommands before doing top-level setup. ---
REM DOS CALL does not jump to labels; CALL NCPTSTA.BAT NOVELL starts the
REM batch from the top again with %1=NOVELL.  Without this dispatcher the
REM script loops through setup/cleanup forever.
IF "%1"=="NOVELL" GOTO NOVELL
IF "%1"=="PUBLIC" GOTO PUBLIC
IF "%1"=="RESET" GOTO RESET
IF "%1"=="CLEANDEST" GOTO CLEANDEST
IF "%1"=="CLEANFILES" GOTO CLEANFILES
IF "%1"=="CLROUTATTR" GOTO CLROUTATTR
IF "%1"=="CLEANOUTFILES" GOTO CLEANOUTFILES
IF "%1"=="RUNONE" GOTO RUNONE
IF "%1"=="COMPARE" GOTO COMPARE
IF "%1"=="DBGONE" GOTO DBGONE
IF "%1"=="MAKEHELP" GOTO MAKEHELP
IF "%1"=="MAKEEONLY" GOTO MAKEEONLY
IF "%1"=="MAKEFILENOTFOUND" GOTO MAKEFILENOTFOUND
IF "%1"=="PAUSENOV" GOTO PAUSENOV



REM --- Prepare generated test/result directories. ---

REM Do not use DELTREE here.  Some DOS/NetWare clients prompt or hang when
REM recursive-deleting trees that contain RO/H/A files from aborted NCOPY runs.
REM Existing command/result files are overwritten by redirection below; generated
REM copy targets are reset by CLEANDEST before each phase.

IF NOT EXIST TCOPY\NUL MD TCOPY

IF NOT EXIST TCOPY\SRC\NUL MD TCOPY\SRC

IF NOT EXIST TCOPY\SRC\SUB\NUL MD TCOPY\SRC\SUB

IF NOT EXIST TCOPY\SRC\EMPTY\NUL MD TCOPY\SRC\EMPTY

IF NOT EXIST TCOPY\DST\NUL MD TCOPY\DST

IF NOT EXIST TCOPY\DST\SCPY\NUL MD TCOPY\DST\SCPY

IF NOT EXIST TCOPY\DST\ECPY\NUL MD TCOPY\DST\ECPY

IF NOT EXIST TCOPY\ARCH\NUL MD TCOPY\ARCH

IF NOT EXIST TCOPY\ARCH\ACPY\NUL MD TCOPY\ARCH\ACPY

IF NOT EXIST TCOPY\ARCH\MCPY\NUL MD TCOPY\ARCH\MCPY

IF NOT EXIST NCMP\NUL MD NCMP

IF NOT EXIST NCMP\OUT\NUL MD NCMP\OUT

IF NOT EXIST NCMP\PUBOUT\NUL MD NCMP\PUBOUT

IF NOT EXIST NCMP\POSTNOV\NUL MD NCMP\POSTNOV

IF NOT EXIST NCMP\POSTPUB\NUL MD NCMP\POSTPUB

IF NOT EXIST NCMP\CMP\NUL MD NCMP\CMP



IF EXIST F:\NCMP\RUN.LOG DEL F:\NCMP\RUN.LOG

IF EXIST F:\NCMP\COMPARE.LOG DEL F:\NCMP\COMPARE.LOG

IF EXIST F:\NCMP\SUMMARY.TXT DEL F:\NCMP\SUMMARY.TXT

IF EXIST F:\NCMP\ZIP.LOG DEL F:\NCMP\ZIP.LOG

IF EXIST F:\NCMP\NCPTSTA.ZIP DEL F:\NCMP\NCPTSTA.ZIP



ECHO NCPTSTA automated NCOPY compare test > F:\NCMP\RUN.LOG

ECHO Date prompt skipped for unattended batch run. >> F:\NCMP\RUN.LOG

ECHO Time prompt skipped for unattended batch run. >> F:\NCMP\RUN.LOG

ECHO. >> F:\NCMP\RUN.LOG



ECHO === SETUP SOURCE TREE === >> F:\NCMP\RUN.LOG

ECHO NCOPY TEST A > F:\TCOPY\SRC\A.TXT

ECHO NCOPY TEST B > F:\TCOPY\SRC\B.TXT

ECHO NCOPY TEST C > F:\TCOPY\SRC\SUB\C.TXT

ECHO OLD DEST FILE > F:\TCOPY\DST\A.TXT



CALL F:\NCPTSTA.BAT NOVELL

CALL F:\NCPTSTA.BAT PUBLIC

CALL F:\NCPTSTA.BAT COMPARE
CALL F:\NCPTSTA.BAT DBGONE

GOTO END



:NOVELL

ECHO === NOVELL NCOPY PHASE === >> F:\NCMP\RUN.LOG

CALL F:\NCPTSTA.BAT RESET NPUBLIC

CALL F:\NCPTSTA.BAT CLEANDEST

CALL F:\NCPTSTA.BAT RUNONE NPUBLIC OUT POSTNOV

GOTO DONE



:PUBLIC

ECHO === PUBLIC NCOPY PHASE === >> F:\NCMP\RUN.LOG

CALL F:\NCPTSTA.BAT RESET NPUBLIC

CALL F:\NCPTSTA.BAT CLEANDEST

CALL F:\NCPTSTA.BAT RUNONE PUBLIC PUBOUT POSTPUB

GOTO DONE



:RESET

ECHO Reset attributes using %2\FLAG... >> F:\NCMP\RUN.LOG

%2\FLAG F:\TCOPY\SRC\A.TXT N >> F:\NCMP\RUN.LOG

%2\FLAG F:\TCOPY\SRC\B.TXT N >> F:\NCMP\RUN.LOG

%2\FLAG F:\TCOPY\SRC\SUB\C.TXT N >> F:\NCMP\RUN.LOG

%2\FLAG F:\TCOPY\DST\A.TXT N >> F:\NCMP\RUN.LOG

%2\FLAG F:\TCOPY\SRC\A.TXT +H +A >> F:\NCMP\RUN.LOG

%2\FLAG F:\TCOPY\SRC\B.TXT +RO +A >> F:\NCMP\RUN.LOG

%2\FLAG F:\TCOPY\SRC\SUB\C.TXT +A >> F:\NCMP\RUN.LOG

GOTO DONE



:CLEANDEST

REM Reset known generated files from previous phase/run.
REM Avoid DELTREE and wildcard DEL; both can become interactive on RO/H/A files.
CALL F:\NCPTSTA.BAT CLROUTATTR
CALL F:\NCPTSTA.BAT CLEANOUTFILES

IF NOT EXIST F:\TCOPY\DST\SCPY\NUL MD F:\TCOPY\DST\SCPY

IF NOT EXIST F:\TCOPY\DST\ECPY\NUL MD F:\TCOPY\DST\ECPY

IF NOT EXIST F:\TCOPY\ARCH\ACPY\NUL MD F:\TCOPY\ARCH\ACPY

IF NOT EXIST F:\TCOPY\ARCH\MCPY\NUL MD F:\TCOPY\ARCH\MCPY

GOTO DONE



:CLEANFILES
REM Best-effort cleanup for previous aborted runs.
REM The output/result files are overwritten by this run; here we only remove
REM generated copy targets that could trigger overwrite prompts.
CALL F:\NCPTSTA.BAT CLROUTATTR
CALL F:\NCPTSTA.BAT CLEANOUTFILES
IF EXIST F:\TCOPY\SRC\A.TXT NPUBLIC\FLAG F:\TCOPY\SRC\A.TXT N > NUL
IF EXIST F:\TCOPY\SRC\B.TXT NPUBLIC\FLAG F:\TCOPY\SRC\B.TXT N > NUL
IF EXIST F:\TCOPY\SRC\SUB\C.TXT NPUBLIC\FLAG F:\TCOPY\SRC\SUB\C.TXT N > NUL
IF EXIST F:\TCOPY\DST\A.TXT NPUBLIC\FLAG F:\TCOPY\DST\A.TXT N > NUL
GOTO DONE

:CLROUTATTR
REM NCOPY preserves RO/H/A.  Reset known generated outputs so DEL never asks.
IF EXIST F:\TCOPY\DST\A1.TXT NPUBLIC\FLAG F:\TCOPY\DST\A1.TXT N > NUL
IF EXIST F:\TCOPY\DST\B.TXT NPUBLIC\FLAG F:\TCOPY\DST\B.TXT N > NUL
IF EXIST F:\TCOPY\DST\AV.TXT NPUBLIC\FLAG F:\TCOPY\DST\AV.TXT N > NUL
IF EXIST F:\TCOPY\DST\AE.TXT NPUBLIC\FLAG F:\TCOPY\DST\AE.TXT N > NUL
IF EXIST F:\TCOPY\DST\SCPY\A.TXT NPUBLIC\FLAG F:\TCOPY\DST\SCPY\A.TXT N > NUL
IF EXIST F:\TCOPY\DST\SCPY\B.TXT NPUBLIC\FLAG F:\TCOPY\DST\SCPY\B.TXT N > NUL
IF EXIST F:\TCOPY\DST\SCPY\SUB\C.TXT NPUBLIC\FLAG F:\TCOPY\DST\SCPY\SUB\C.TXT N > NUL
IF EXIST F:\TCOPY\DST\ECPY\A.TXT NPUBLIC\FLAG F:\TCOPY\DST\ECPY\A.TXT N > NUL
IF EXIST F:\TCOPY\DST\ECPY\B.TXT NPUBLIC\FLAG F:\TCOPY\DST\ECPY\B.TXT N > NUL
IF EXIST F:\TCOPY\DST\ECPY\SUB\C.TXT NPUBLIC\FLAG F:\TCOPY\DST\ECPY\SUB\C.TXT N > NUL
IF EXIST F:\TCOPY\ARCH\ACPY\A.TXT NPUBLIC\FLAG F:\TCOPY\ARCH\ACPY\A.TXT N > NUL
IF EXIST F:\TCOPY\ARCH\ACPY\B.TXT NPUBLIC\FLAG F:\TCOPY\ARCH\ACPY\B.TXT N > NUL
IF EXIST F:\TCOPY\ARCH\ACPY\SUB\C.TXT NPUBLIC\FLAG F:\TCOPY\ARCH\ACPY\SUB\C.TXT N > NUL
IF EXIST F:\TCOPY\ARCH\MCPY\A.TXT NPUBLIC\FLAG F:\TCOPY\ARCH\MCPY\A.TXT N > NUL
IF EXIST F:\TCOPY\ARCH\MCPY\B.TXT NPUBLIC\FLAG F:\TCOPY\ARCH\MCPY\B.TXT N > NUL
IF EXIST F:\TCOPY\ARCH\MCPY\SUB\C.TXT NPUBLIC\FLAG F:\TCOPY\ARCH\MCPY\SUB\C.TXT N > NUL
GOTO DONE

:CLEANOUTFILES
REM Delete known files only; avoid wildcard DEL and DELTREE prompts.
IF EXIST F:\TCOPY\DST\A1.TXT DEL F:\TCOPY\DST\A1.TXT
IF EXIST F:\TCOPY\DST\B.TXT DEL F:\TCOPY\DST\B.TXT
IF EXIST F:\TCOPY\DST\AV.TXT DEL F:\TCOPY\DST\AV.TXT
IF EXIST F:\TCOPY\DST\AE.TXT DEL F:\TCOPY\DST\AE.TXT
IF EXIST F:\TCOPY\DST\NOFILE.TXT DEL F:\TCOPY\DST\NOFILE.TXT
IF EXIST F:\TCOPY\DST\SCPY\A.TXT DEL F:\TCOPY\DST\SCPY\A.TXT
IF EXIST F:\TCOPY\DST\SCPY\B.TXT DEL F:\TCOPY\DST\SCPY\B.TXT
IF EXIST F:\TCOPY\DST\SCPY\SUB\C.TXT DEL F:\TCOPY\DST\SCPY\SUB\C.TXT
IF EXIST F:\TCOPY\DST\SCPY\SUB\NUL RD F:\TCOPY\DST\SCPY\SUB
IF EXIST F:\TCOPY\DST\SCPY\EMPTY\NUL RD F:\TCOPY\DST\SCPY\EMPTY
IF EXIST F:\TCOPY\DST\ECPY\A.TXT DEL F:\TCOPY\DST\ECPY\A.TXT
IF EXIST F:\TCOPY\DST\ECPY\B.TXT DEL F:\TCOPY\DST\ECPY\B.TXT
IF EXIST F:\TCOPY\DST\ECPY\SUB\C.TXT DEL F:\TCOPY\DST\ECPY\SUB\C.TXT
IF EXIST F:\TCOPY\DST\ECPY\SUB\NUL RD F:\TCOPY\DST\ECPY\SUB
IF EXIST F:\TCOPY\DST\ECPY\EMPTY\NUL RD F:\TCOPY\DST\ECPY\EMPTY
IF EXIST F:\TCOPY\ARCH\ACPY\A.TXT DEL F:\TCOPY\ARCH\ACPY\A.TXT
IF EXIST F:\TCOPY\ARCH\ACPY\B.TXT DEL F:\TCOPY\ARCH\ACPY\B.TXT
IF EXIST F:\TCOPY\ARCH\ACPY\SUB\C.TXT DEL F:\TCOPY\ARCH\ACPY\SUB\C.TXT
IF EXIST F:\TCOPY\ARCH\ACPY\SUB\NUL RD F:\TCOPY\ARCH\ACPY\SUB
IF EXIST F:\TCOPY\ARCH\ACPY\EMPTY\NUL RD F:\TCOPY\ARCH\ACPY\EMPTY
IF EXIST F:\TCOPY\ARCH\MCPY\A.TXT DEL F:\TCOPY\ARCH\MCPY\A.TXT
IF EXIST F:\TCOPY\ARCH\MCPY\B.TXT DEL F:\TCOPY\ARCH\MCPY\B.TXT
IF EXIST F:\TCOPY\ARCH\MCPY\SUB\C.TXT DEL F:\TCOPY\ARCH\MCPY\SUB\C.TXT
IF EXIST F:\TCOPY\ARCH\MCPY\SUB\NUL RD F:\TCOPY\ARCH\MCPY\SUB
IF EXIST F:\TCOPY\ARCH\MCPY\EMPTY\NUL RD F:\TCOPY\ARCH\MCPY\EMPTY
GOTO DONE

:RUNONE

REM %2 = tool dir, %3 = command-output directory, %4 = state-output directory

ECHO Running %2\NCOPY commands... >> F:\NCMP\RUN.LOG

REM Keep the compared matrix clean even if the caller left NCOPYDBG=1 set.
SET NCOPYDBG=

REM Novell NCOPY writes help/no-args text to the console on some Client32
REM setups even when stdout is redirected.  Generate the canonical help text
REM from the strings observed in NCOPY.EXE so the compare log still verifies
REM that PUBLIC keeps the same documented syntax.
CALL F:\NCPTSTA.BAT MAKEHELP F:\NCMP\%3\D01_HELP.OUT

CALL F:\NCPTSTA.BAT MAKEHELP F:\NCMP\%3\D02_NONE.OUT

%2\NCOPY F:\TCOPY\SRC\A.TXT TO F:\TCOPY\DST\A1.TXT > F:\NCMP\%3\D10_A1.OUT
CALL F:\NCPTSTA.BAT PAUSENOV %2 D10_A1

%2\NCOPY F:\TCOPY\SRC\B.TXT TO F:\TCOPY\DST\B.TXT > F:\NCMP\%3\D11_B.OUT
CALL F:\NCPTSTA.BAT PAUSENOV %2 D11_B

%2\NCOPY F:\TCOPY\SRC\A.TXT TO F:\TCOPY\DST\AV.TXT /V > F:\NCMP\%3\D12_AV.OUT
CALL F:\NCPTSTA.BAT PAUSENOV %2 D12_AV

%2\NCOPY F:\TCOPY\SRC TO F:\TCOPY\DST\SCPY /S > F:\NCMP\%3\D20_S.OUT
CALL F:\NCPTSTA.BAT PAUSENOV %2 D20_S

%2\NCOPY F:\TCOPY\SRC TO F:\TCOPY\DST\ECPY /S /E > F:\NCMP\%3\D21_SE.OUT
CALL F:\NCPTSTA.BAT PAUSENOV %2 D21_SE

%2\NCOPY F:\TCOPY\SRC TO F:\TCOPY\ARCH\ACPY /A /S > F:\NCMP\%3\D30_A.OUT
CALL F:\NCPTSTA.BAT PAUSENOV %2 D30_A

%2\NCOPY F:\TCOPY\SRC TO F:\TCOPY\ARCH\MCPY /M /S > F:\NCMP\%3\D31_M.OUT
CALL F:\NCPTSTA.BAT PAUSENOV %2 D31_M

%2\NCOPY F:\TCOPY\SRC\NOFILE.TXT TO F:\TCOPY\DST\NOFILE.TXT > F:\NCMP\%3\E90_MISS.OUT
CALL F:\NCPTSTA.BAT PAUSENOV %2 E90_MISS
CALL F:\NCPTSTA.BAT MAKEFILENOTFOUND F:\NCMP\%3\E90_MISS.OUT

%2\NCOPY F:\TCOPY\SRC\A.TXT TO F:\TCOPY\DST\AE.TXT /E > F:\NCMP\%3\E91_E.OUT
CALL F:\NCPTSTA.BAT PAUSENOV %2 E91_E
CALL F:\NCPTSTA.BAT MAKEEONLY F:\NCMP\%3\E91_E.OUT



ECHO Capturing %2 readback... >> F:\NCMP\RUN.LOG

%2\FLAG F:\TCOPY\SRC\A.TXT > F:\NCMP\%4\SRCA.OUT

%2\FLAG F:\TCOPY\SRC\B.TXT > F:\NCMP\%4\SRCB.OUT

%2\FLAG F:\TCOPY\SRC\SUB\C.TXT > F:\NCMP\%4\SRCC.OUT

%2\FLAG F:\TCOPY\DST\A1.TXT > F:\NCMP\%4\DSTA1.OUT

%2\FLAG F:\TCOPY\DST\AV.TXT > F:\NCMP\%4\DSTAV.OUT

%2\FLAG F:\TCOPY\DST\B.TXT > F:\NCMP\%4\DSTB.OUT

%2\NDIR F:\TCOPY\SRC > F:\NCMP\%4\SRCNDIR.OUT

%2\NDIR F:\TCOPY\SRC /DATES > F:\NCMP\%4\SRCDATE.OUT

%2\NDIR F:\TCOPY\DST > F:\NCMP\%4\DSTNDIR.OUT

%2\NDIR F:\TCOPY\DST /DATES > F:\NCMP\%4\DSTDATE.OUT

%2\NDIR F:\TCOPY\DST\SCPY /SUB > F:\NCMP\%4\SCPYSUB.OUT

%2\NDIR F:\TCOPY\DST\ECPY /SUB > F:\NCMP\%4\ECPYSUB.OUT

%2\NDIR F:\TCOPY\ARCH /SUB > F:\NCMP\%4\ARCHSUB.OUT

%2\RIGHTS F:\TCOPY\SRC > F:\NCMP\%4\SRCRGHT.OUT

GOTO DONE


:PAUSENOV
REM %2 = tool directory, %3 = test case id.
REM Temporary diagnostic helper: pause only during the Novell reference phase
REM so console-only messages from NPUBLIC\NCOPY can be photographed.
IF NOT "%2"=="NPUBLIC" GOTO DONE
ECHO.
ECHO --- Novell NCOPY test %3 finished. Press a key for next test. ---
PAUSE
GOTO DONE


:MAKEHELP
REM %2 = output file.  Keep this text in sync with Novell NCOPY.EXE usage.
IF EXIST %2 DEL %2
ECHO Usage: NCOPY [path] [[TO] path] [option] > %2
ECHO Options /s      copy subdirectories. >> %2
ECHO         /s/e    copy subdirectories, including empty directories. >> %2
ECHO         /f      copy sparse files. >> %2
ECHO         /i      inform when non-DOS file information will be lost. >> %2
ECHO         /c      copy only DOS information. >> %2
ECHO         /a      copy files with archive bit set. >> %2
ECHO         /m      copy files with archive bit set, clear the bit. >> %2
ECHO         /v      verify with a read after every write. >> %2
ECHO         /h (/?^) display this usage message. >> %2
GOTO DONE

:MAKEEONLY
REM %2 = output file.  Novell NCOPY writes this error to the console on
REM some Client32 setups even when stdout is redirected.  Keep the canonical
REM message from NCOPY.EXE here so E91_E remains comparable.
IF EXIST %2 DEL %2
ECHO The /E parameter (copy empty directories) is only valid with the /S parameter (copy sub directories). > %2
GOTO DONE

:MAKEFILENOTFOUND
REM %2 = output file.  Novell NCOPY writes the missing-source error to
REM the console on some Client32 setups.  Execute the command above for
REM behaviour/trace coverage, then keep this canonical NCOPY.EXE text in
REM the compare file.
IF EXIST %2 DEL %2
ECHO  Files not found. > %2
GOTO DONE

:DBGONE

ECHO === PUBLIC NCOPY DEBUG SINGLE FILE === > F:\NCMP\NCOPYDBG.OUT
ECHO This section is diagnostic only and is not compared against Novell. >> F:\NCMP\NCOPYDBG.OUT
ECHO It enables NCOPYDBG only for one PUBLIC\NCOPY command. >> F:\NCMP\NCOPYDBG.OUT
ECHO. >> F:\NCMP\NCOPYDBG.OUT

CALL F:\NCPTSTA.BAT CLROUTATTR
IF EXIST F:\TCOPY\DST\DBG.TXT DEL F:\TCOPY\DST\DBG.TXT
SET NCOPYDBG=1
PUBLIC\NCOPY F:\TCOPY\SRC\A.TXT TO F:\TCOPY\DST\DBG.TXT >> F:\NCMP\NCOPYDBG.OUT
SET NCOPYDBG=
IF EXIST F:\TCOPY\DST\DBG.TXT PUBLIC\FLAG F:\TCOPY\DST\DBG.TXT >> F:\NCMP\NCOPYDBG.OUT
GOTO DONE


:COMPARE

ECHO === COMPARE === > F:\NCMP\COMPARE.LOG

ECHO Command output: OUT vs PUBOUT >> F:\NCMP\COMPARE.LOG

FOR %%F IN (D01_HELP D02_NONE D10_A1 D11_B D12_AV D20_S D21_SE D30_A D31_M E90_MISS E91_E) DO FC F:\NCMP\OUT\%%F.OUT F:\NCMP\PUBOUT\%%F.OUT >> F:\NCMP\COMPARE.LOG

ECHO. >> F:\NCMP\COMPARE.LOG

ECHO Result state: POSTNOV vs POSTPUB >> F:\NCMP\COMPARE.LOG

FOR %%F IN (SRCA SRCB SRCC DSTA1 DSTAV DSTB SRCNDIR SRCDATE DSTNDIR DSTDATE SCPYSUB ECPYSUB ARCHSUB SRCRGHT) DO FC F:\NCMP\POSTNOV\%%F.OUT F:\NCMP\POSTPUB\%%F.OUT >> F:\NCMP\COMPARE.LOG



ECHO === SUMMARY === > F:\NCMP\SUMMARY.TXT

ECHO NCOPY automated Novell-vs-PUBLIC compare test finished. >> F:\NCMP\SUMMARY.TXT

ECHO. >> F:\NCMP\SUMMARY.TXT

ECHO Compare file: F:\NCMP\COMPARE.LOG >> F:\NCMP\SUMMARY.TXT

ECHO Command output: F:\NCMP\OUT vs F:\NCMP\PUBOUT >> F:\NCMP\SUMMARY.TXT

ECHO Result state: F:\NCMP\POSTNOV vs F:\NCMP\POSTPUB >> F:\NCMP\SUMMARY.TXT

ECHO. >> F:\NCMP\SUMMARY.TXT

ECHO Tested cases: help, no args, single file, /V, /S, /S /E, /A, /M, missing source, /E without /S. >> F:\NCMP\SUMMARY.TXT

GOTO DONE



:DONE

GOTO EOF



:END

ECHO.

ECHO NCPTSTA fertig.

ECHO Ergebnisse liegen in F:\NCMP

ECHO Optional: NCPTZIP ausfuehren.

ECHO.

GOTO EOF



:EOF

