home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Troubleshooting Netware Systems
/
CSTRIAL0196.BIN
/
attach
/
pcc
/
v08n03
/
netwrk.exe
/
CLONE1_1.ZIP
/
REPLICA.B2C
< prev
next >
Wrap
Text File
|
1993-01-07
|
17KB
|
511 lines
echo off
if "%1"==".entry1" goto entry1
if "%1"==".entry2" goto entry2
if "%1"==".sub1" goto sub1
if "%1"==".sub2" goto sub2
if "%1"==".filspec" goto filspec
if "%1"==".sub4" goto sub4
if "%2"==".sub5" goto sub5
if "%1"==".sub6" goto sub6
echo REPLICA vs. 1.1 receives a complete drive, or a part of it (branch) serially
echo from another machine into a specific subdirectory. (c) 1993, Jim Groeneveld, NL
echo.
rem Necessary auxiliary files: SUBST.*, FIND.* (DOS) and ZIP.COM (vs. 1.51)
if "%1"=="" goto help
if "%1"=="?" goto help
if "%1"=="/?" goto help
if "%1"=="-?" goto help
if "%1"=="/h" goto help
if "%1"=="/H" goto help
echo Wait.............processing arguments..................
REM The two 'FOR' lines below activate a bug in the BATch compiler if wildcards
REM are specified. Their function has been reprogrammed differently.
REM Compiler: BAT2EXEC 1.5 (c) 1990, 1991 Ziff Communications Co.
REM PC Magazine ■ Douglas Boling.
REM for %%a in (%1 %2 %3 %4 %5 %6 %7 %8 %9) do if "%%a"==".s" goto repeat_1
REM for %%a in (%1 %2 %3 %4 %5 %6 %7 %8 %9) do if "%%a"==".S" goto repeat_1
REM (although wildcards are not being expected as parameters of REPLICA)
for %%a in (s S) do if "%1"==".%%a" goto repeat_1
for %%a in (s S) do if "%2"==".%%a" goto repeat_1
for %%a in (s S) do if "%3"==".%%a" goto repeat_1
for %%a in (s S) do if "%4"==".%%a" goto repeat_1
for %%a in (s S) do if "%5"==".%%a" goto repeat_1
for %%a in (s S) do if "%6"==".%%a" goto repeat_1
for %%a in (s S) do if "%7"==".%%a" goto repeat_1
for %%a in (s S) do if "%8"==".%%a" goto repeat_1
for %%a in (s S) do if "%9"==".%%a" goto repeat_1
goto chk_tmp
:repeat_1
%0 .sub1 %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
goto exit
rem never pass here!
:entry1
shift
shift
if "%1"=="" goto help
goto no_filspec
:chk_tmp
if not exist $dirlist.bat goto no_dirlist
echo *** Temporary file $DIRLIST.BAT already exists, cannot proceed;
echo remove or rename $DIRLIST.BAT or specify '.s' option.
goto end
:no_dirlist
if not exist $fillist.bat goto no_fillist
echo *** Temporary file $FILLIST.BAT already exists, cannot proceed;
echo remove or rename $FILLIST.BAT or specify '.s' option.
goto end
:no_fillist
if not exist $filspec.bat goto no_filspec
echo *** Temporary file $FILSPEC.BAT already exists, cannot proceed;
echo remove or rename $FILSPEC.BAT or specify '.s' option.
goto end
:no_filspec
if exist $dirlist.bat del $dirlist.bat
if exist $dirlist.bat goto $dirlist
if exist $fillist.bat del $fillist.bat
if exist $fillist.bat goto $fillist
if exist $filspec.bat del $filspec.bat
if exist $filspec.bat goto $filspec
rem Search %2 for optional legal parameter:
if "%2"=="" goto OK_2
rem Exclude all possible legal parameters (see file UNDOCU'D.DOS)
for %%a in (x X s S) do if "%2"==".%%a" goto OK_2
for %%a in (1 2 3 4) do if "%2"=="/%%a" goto OK_2
for %%a in (b115200 b57600 b38400 b19200 b9600 b4800 b2400) do if "%2"=="/%%a" goto OK_2
for %%a in (B115200 B57600 B38400 B19200 B9600 B4800 B2400) do if "%2"=="/%%a" goto OK_2
for %%a in (b11520 b5760 b3840 b1920 b960 b480 b240) do if "%2"=="/%%a" goto OK_2
for %%a in (B11520 B5760 B3840 B1920 B960 B480 B240) do if "%2"=="/%%a" goto OK_2
for %%a in (b1152 b576 b384 b192 b96 b48 b24) do if "%2"=="/%%a" goto OK_2
for %%a in (B1152 B576 B384 B192 B96 B48 B24) do if "%2"=="/%%a" goto OK_2
for %%a in (b115 b11 b57 b38 b19 B115 B11 B57 B38 B19) do if "%2"=="/%%a" goto OK_2
goto error2 rem or remove the check completely!
:OK_2
rem if "%1"=="\" goto error1 These subst path specifications appear to
rem if "%1"=="." goto error1 work correctly, as does any relative path
rem if "%1"==".." goto error1 specification, at least with DOS 3.3 .
for %%a in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do if "%1"=="%%a" goto error1
for %%a in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if "%1"=="%%a" goto error1
for %%a in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do if "%1"=="%%a:" goto error1
for %%a in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if "%1"=="%%a:" goto error1
if "%1"=="z:\" goto error1
if "%1"=="Z:\" goto error1
for %%a in (a b c d e f g h i j k l m n o p q r s t u v w x y) do if "%1"=="%%a:\" goto begin
for %%a in (A B C D E F G H I J K L M N O P Q R S T U V W X Y) do if "%1"=="%%a:\" goto begin
if exist %1 goto is_file
if exist %1\$chkpath.nul del %1\$chkpath.nul
if exist %1\$chkpath.nul goto 1_exists
if exist %1\*.* goto begin
ctty nul
rem>%1\$chkpath.nul
ctty con
if not exist %1\$chkpath.nul goto not_existing
:begin0
if exist %1\$chkpath.nul del %1\$chkpath.nul
:begin
if exist Z:\*.* goto z_exists
ctty nul
rem>Z:\$chkpath.nul
ctty con
if not exist Z:\$chkpath.nul goto nosubstz
del Z:\$chkpath.nul
:z_exists
echo --- Existing substitution or network assignment drive of Z: will be lost;
echo drive Z will be temporarily substituted as %1
echo Restore original substitution after termination of this program:
subst|find "Z:"
net use|find "Z:"
echo (Ignore eventual "Bad command or file name" above...........)
:nosubstz
rem If Z: is write protected its existence can not be checked. So to be
rem sure Z: is being freed below from substitution or network assignment.
subst z: /d >nul
rem disconnect drive Z: from network, ignore eventual error message..........
ctty nul
net use z: /d >nul
ctty con
rem check whether Z: now indeed does not exist
if not exist Z:\*.* goto mount
ctty nul
rem>Z:\$chkpath.nul
ctty con
if not exist Z:\$chkpath.nul goto mount
del Z:\$chkpath.nul
echo *** Existing drive Z:\ could not be disconnected successfully.
echo It still may be ASSIGNed or otherwise existing. Program abort!
goto beep
:mount
rem substitute Z: to specified drive:\path to transfer
subst z: %1 >nul
rem and check whether substitution succeeded
if exist Z:\$chkpath.nul del Z:\$chkpath.nul
if exist Z:\$chkpath.nul goto no_z_nul
if exist Z:\*.* goto begin2
ctty nul
rem>Z:\$chkpath.nul
ctty con
if not exist Z:\$chkpath.nul goto no_z_nul
del Z:\$chkpath.nul
:begin2
echo --- receive subdirectory structure $DIRLIST.BAT, filelist $FILLIST.BAT
echo and filespec $FILSPEC.BAT (in current drive\dir)
rem without eventual parameter .x
%0 .sub2 %0 %2 %3 %4 %5 %6 %7 %8 %9
if not exist $dirlist.bat goto nodirlist
if not exist $fillist.bat goto nofillist
if not exist $filspec.bat goto nofilspec
rem restart with obtained filespec from $FILSPEC.BAT as %2
$filspec %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
rem Actual final termination of compiled batch file (.B2C) takes place here.
rem Final deletion of $FILSPEC.BAT only after finishing its run,
rem otherwise "Batch file missing" and "Bad command or file name"
rem occur after ending %0 from $FILSPEC above:
if exist $filspec.bat del $filspec.bat
if exist $filspec.bat echo delete $FILSPEC.BAT yourself.
goto exit
:file_spec
echo --- Replicating branch: %1, file specification: %2
if not "%3"=="" echo Additional option(s): %3 %4 %5 %6 %7 %8 %9
echo --- create subdir structure from list (in specified drive\dir)
$dirlist echo
ctty nul
$dirlist md
ctty con
echo --- check whether they exist (already, if unable to create)
$dirlist %0 .sub5
rem eventual check for existing target files if _no_ '.x' parameter
REM The two 'FOR' lines below activate a bug in the BATch compiler if wildcards
REM are specified. Their function has been reprogrammed differently.
REM Compiler: BAT2EXEC 1.5 (c) 1990, 1991 Ziff Communications Co.
REM PC Magazine ■ Douglas Boling.
REM for %%a in (%3 %4 %5 %6 %7 %8 %9) do if "%%a"==".x" goto repeat_2
REM for %%a in (%3 %4 %5 %6 %7 %8 %9) do if "%%a"==".X" goto repeat_2
REM (although wildcards are not being expected as parameters of REPLICA)
REM (but a wildcard file specification may come from $FILSPEC.BAT)
for %%a in (x X) do if "%3"==".%%a" goto repeat_2
for %%a in (x X) do if "%4"==".%%a" goto repeat_2
for %%a in (x X) do if "%5"==".%%a" goto repeat_2
for %%a in (x X) do if "%6"==".%%a" goto repeat_2
for %%a in (x X) do if "%7"==".%%a" goto repeat_2
for %%a in (x X) do if "%8"==".%%a" goto repeat_2
for %%a in (x X) do if "%9"==".%%a" goto repeat_2
goto chkfiles
:repeat_2
%0 .sub4 %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
goto exit rem never pass here!
:chkfiles
$fillist %2 %0 .sub6
goto no-chk
:entry2
shift
shift
:no-chk
echo --- receive files (in specified drive\dir)
zip /s %3 %4 %5 %6 %7 %8 %9
if errorlevel 1 goto error4
echo === all files successfully received and server successfully unlinked
rem server will be unlinked by client
:finish
subst z: /d >nul
if exist $dirlist.bat del $dirlist.bat
if exist $dirlist.bat echo delete $DIRLIST.BAT yourself.
if exist $fillist.bat del $fillist.bat
if exist $fillist.bat echo delete $FILLIST.BAT yourself.
rem if exist $filspec.bat del $filspec.bat +Moved to actual
rem if exist $filspec.bat echo delete $FILSPEC.BAT yourself. +final termination.
echo === Termination of REPLICA ===
goto end
:$dirlist
echo *** Unable to delete (or overwrite later) $DIRLIST.BAT
goto $explain
:$fillist
echo *** Unable to delete (or overwrite later) $FILLIST.BAT
goto $explain
:$filspec
echo *** Unable to delete (or overwrite later) $FILSPEC.BAT
:$explain
echo File and/or disk may be write protected, unprotect it/them.
goto end
:error1
echo *** Illegal target path specification %1 ***
goto beep
:error2
echo *** Illegal parameter %2 ***
goto beep
:error4
if errorlevel 128 goto finish
echo *** An error occurred while receiving all files (see above)
echo Abort sending end manually if not already automatically
echo and try again (maybe using a different speed).
goto finish
:nodirlist
echo *** $DIRLIST.BAT apparently not received. Cannot proceed. Program abort!
goto finish
:nofillist
echo *** $FILLIST.BAT apparently not received. Cannot proceed. Program abort!
goto finish
:nofilspec
echo *** $FILSPEC.BAT apparently not received. Cannot proceed. Program abort!
goto finish
:no_z_nul
echo *** Impossible to install auxiliary substituted drive Z:.
echo - Maybe the external DOS SUBST command is not available.
echo - Maybe the necessary line "LASTDRIVE=Z" lacks in CONFIG.SYS.
echo - Maybe an already substituted or network drive has been specified;
echo only logical drives may be specified.
echo - Maybe an original drive Z: is write protected.
echo - Maybe the disk with %1 is write protected.
echo - (maybe only temporary check file $CHKPATH.NUL is write protected).
echo - Or maybe a wrong syntax has been applied (see below).
echo Correct and try again.
goto beep
:not_existing
ctty nul
md %1
rem>%1\$chkpath.nul
ctty con
if exist %1\$chkpath.nul goto begin0
echo *** Specified «drive»«path» %1 does not exist
echo and cannot be created or the disk may be write protected.
echo Remove eventual protection or create %1 manually firstly.
echo Program abort!
goto beep
:1_exists
echo *** Specified «drive»«path» %1 is write protected
echo (or only temporary check file $CHKPATH.NUL is write protected).
echo Remove protection. Program abort!
goto beep
:is_file
echo *** Specified «drive»«path» %1 is a file, not a subdirectory.
echo Program abort!
goto beep
:beep
echo
:help
echo Usage: "REPLICA «drive»«path» [options]" of receiving subdirectory,
echo with «drive» = logical (not substituted) drive A..Y (not Z:),
echo and «path» = complete pathname, without trailing \, unless root,
echo and [options] = one or more of optional parameters below:
echo .s : skip initial test for temporary scratch files
echo .x : skip check for existing files in target directories
echo see also ( /1│/2│/3│/4 : COM port number
echo ZIP.DOC ( /Bbaudrate : sets baudrate
echo Example: "REPLICA C:\" or "REPLICA D:\WORK\TEXTS /2 .X".
echo.
echo On the sending end the following has to be entered:
echo "CLONE «drive»«path» [«filespec»] [options]" of subdirectory to transfer.
goto end
:sub1
shift
shift
rem Remove .s .S from parameters and restart batch file................
for %%a in (s S) do if "%1"==".%%a" goto s1
for %%a in (s S) do if "%2"==".%%a" goto s2
for %%a in (s S) do if "%3"==".%%a" goto s3
for %%a in (s S) do if "%4"==".%%a" goto s4
for %%a in (s S) do if "%5"==".%%a" goto s5
for %%a in (s S) do if "%6"==".%%a" goto s6
for %%a in (s S) do if "%7"==".%%a" goto s7
for %%a in (s S) do if "%8"==".%%a" goto s8
for %%a in (s S) do if "%9"==".%%a" goto s9
%0 .entry1 %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
goto exit
:s1
%0 .sub1 %0 %2 %3 %4 %5 %6 %7 %8 %9
goto exit
:s2
%0 .sub1 %0 %1 %3 %4 %5 %6 %7 %8 %9
goto exit
:s3
%0 .sub1 %0 %1 %2 %4 %5 %6 %7 %8 %9
goto exit
:s4
%0 .sub1 %0 %1 %2 %3 %5 %6 %7 %8 %9
goto exit
:s5
%0 .sub1 %0 %1 %2 %3 %4 %6 %7 %8 %9
goto exit
:s6
%0 .sub1 %0 %1 %2 %3 %4 %5 %7 %8 %9
goto exit
:s7
%0 .sub1 %0 %1 %2 %3 %4 %5 %6 %8 %9
goto exit
:s8
%0 .sub1 %0 %1 %2 %3 %4 %5 %6 %7 %9
goto exit
:s9
%0 .sub1 %0 %1 %2 %3 %4 %5 %6 %7 %8
goto exit
:sub2
shift
shift
rem Remove .x .X temporary from parameters and execute ZIP................
for %%a in (x X) do if "%1"==".%%a" goto x1
for %%a in (x X) do if "%2"==".%%a" goto x2
for %%a in (x X) do if "%3"==".%%a" goto x3
for %%a in (x X) do if "%4"==".%%a" goto x4
for %%a in (x X) do if "%5"==".%%a" goto x5
for %%a in (x X) do if "%6"==".%%a" goto x6
for %%a in (x X) do if "%7"==".%%a" goto x7
for %%a in (x X) do if "%8"==".%%a" goto x8
zip /r[] %1 %2 %3 %4 %5 %6 %7 %8
if errorlevel 1 goto error3
echo === subdirectory structure $DIRLIST.BAT, filelist $FILLIST.BAT
echo and filespec $FILSPEC.BAT successfully received
:recover1
goto exit
:error3
echo *** An error occurred while sending $DIRLIST.BAT, $FILLIST.BAT and $FILSPEC.BAT
echo (see above)
goto recover1
:x1
%0 .sub2 %0 %2 %3 %4 %5 %6 %7 %8
goto exit
:x2
%0 .sub2 %0 %1 %3 %4 %5 %6 %7 %8
goto exit
:x3
%0 .sub2 %0 %1 %2 %4 %5 %6 %7 %8
goto exit
:x4
%0 .sub2 %0 %1 %2 %3 %5 %6 %7 %8
goto exit
:x5
%0 .sub2 %0 %1 %2 %3 %4 %6 %7 %8
goto exit
:x6
%0 .sub2 %0 %1 %2 %3 %4 %5 %7 %8
goto exit
:x7
%0 .sub2 %0 %1 %2 %3 %4 %5 %6 %8
goto exit
:x8
%0 .sub2 %0 %1 %2 %3 %4 %5 %6 %7
goto exit
:filspec
shift
shift
goto file_spec
:sub4
shift
shift
rem Remove .x .X from parameters and restart batch file................
for %%a in (x X) do if "%3"==".%%a" goto c3
for %%a in (x X) do if "%4"==".%%a" goto c4
for %%a in (x X) do if "%5"==".%%a" goto c5
for %%a in (x X) do if "%6"==".%%a" goto c6
for %%a in (x X) do if "%7"==".%%a" goto c7
for %%a in (x X) do if "%8"==".%%a" goto c8
for %%a in (x X) do if "%9"==".%%a" goto c9
%0 .entry2 %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
goto exit
:c3
%0 .sub4 %0 %1 %2 %4 %5 %6 %7 %8 %9
goto exit
:c4
%0 .sub4 %0 %1 %2 %3 %5 %6 %7 %8 %9
goto exit
:c5
%0 .sub4 %0 %1 %2 %3 %4 %6 %7 %8 %9
goto exit
:c6
%0 .sub4 %0 %1 %2 %3 %4 %5 %7 %8 %9
goto exit
:c7
%0 .sub4 %0 %1 %2 %3 %4 %5 %6 %8 %9
goto exit
:c8
%0 .sub4 %0 %1 %2 %3 %4 %5 %6 %7 %9
goto exit
:c9
%0 .sub4 %0 %1 %2 %3 %4 %5 %6 %7 %8
goto exit
:sub5
if exist %1\*.* goto end
if exist %1 goto is-file
ctty nul
rem>%1\$chkpath.nul
ctty con
if not exist %1\$chkpath.nul goto not-existing
del %1\$chkpath.nul
rem %1 is an existing directory
goto end
:is-file
echo.
echo ***************************************************************************
echo *** Replicated specification %1 is an existing file name.
echo Transferring files to this "subdirectory" just hereafter
echo will _NOT_ succeed! REPLICA will continue after you
pause
goto end
:not-existing
echo.
echo ***************************************************************************
echo *** Replicated specification %1
echo could not be created or is write protected.
echo Transferring files to this "subdirectory" just hereafter
echo probably will _NOT_ succeed! REPLICA will continue after you
pause
goto end
:sub6
if not exist %2 goto end
echo.
echo ***************************************************************************
echo !!! Warning: target file specification %2 already exists!
dir %2 /w /p
pause
echo.
echo IF YOU HAVE NOT SPECIFIED THE '/N' OR '/P' PARAMETER ON THE OTHER END (CLONE)
echo THESE FILES MAY BE OVERWRITTEN!
echo IF YOU WISH TO ABORT NOW PRESSING ^C OR Ctrl-Break WILL _NOT_ HELP!
echo YOU CAN ONLY SWITCH OFF YOUR COMPUTER _NOW_ AND TRY AGAIN DIFFERENTLY.
echo IN THAT CASE PRESS 'ESC' ON THE OTHER END AS MANY TIMES AS NECESSARY TO
echo FINISH CLONE OR SWITCH IT OFF TOO AND RESTART.
echo.
echo To avoid these checks and resulting messages specify '.x' option next time.
echo.
echo If you think everything is OK (files may be overwritten or won't) then
pause
goto end
:end
:exit