home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Troubleshooting Netware Systems
/
CSTRIAL0196.BIN
/
attach
/
pcc
/
v08n03
/
netwrk.exe
/
CLONE1_1.ZIP
/
REPLICA.BAT
< prev
next >
Wrap
DOS Batch File
|
1993-01-07
|
14KB
|
392 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..................
for %%a in (%1 %2 %3 %4 %5 %6 %7 %8 %9) do if "%%a"==".s" goto repeat_1
for %%a in (%1 %2 %3 %4 %5 %6 %7 %8 %9) do if "%%a"==".S" goto repeat_1
goto chk_tmp
:repeat_1
%0 .sub1 %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
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
for %%f in (/%2) do if "%%f"=="/" goto OK_2
for %%f in (/%2) do if "%%f"=="." goto OK_2
goto error2
: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
command/c%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
: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)
command/c$dirlist echo
ctty nul
command/c$dirlist md
ctty con
echo --- check whether they exist (already, if unable to create)
command/c$dirlist %0 .sub5
rem eventual check for existing target files if _no_ '.x' parameter
for %%a in (%3 %4 %5 %6 %7 %8 %9) do if "%%a"==".x" goto repeat_2
for %%a in (%3 %4 %5 %6 %7 %8 %9) do if "%%a"==".X" goto repeat_2
goto chkfiles
:repeat_2
%0 .sub4 %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
rem never pass here!
:chkfiles
command/c$fillist %2 command/c%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.
if exist $filspec.bat del $filspec.bat
if exist $filspec.bat echo delete $FILSPEC.BAT yourself.
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" %0 .sub1 %0 %2 %3 %4 %5 %6 %7 %8 %9
for %%a in (s S) do if "%2"==".%%a" %0 .sub1 %0 %1 %3 %4 %5 %6 %7 %8 %9
for %%a in (s S) do if "%3"==".%%a" %0 .sub1 %0 %1 %2 %4 %5 %6 %7 %8 %9
for %%a in (s S) do if "%4"==".%%a" %0 .sub1 %0 %1 %2 %3 %5 %6 %7 %8 %9
for %%a in (s S) do if "%5"==".%%a" %0 .sub1 %0 %1 %2 %3 %4 %6 %7 %8 %9
for %%a in (s S) do if "%6"==".%%a" %0 .sub1 %0 %1 %2 %3 %4 %5 %7 %8 %9
for %%a in (s S) do if "%7"==".%%a" %0 .sub1 %0 %1 %2 %3 %4 %5 %6 %8 %9
for %%a in (s S) do if "%8"==".%%a" %0 .sub1 %0 %1 %2 %3 %4 %5 %6 %7 %9
for %%a in (s S) do if "%9"==".%%a" %0 .sub1 %0 %1 %2 %3 %4 %5 %6 %7 %8
%0 .entry1 %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
rem never pass here!
:sub2
shift
shift
rem Remove .x .X temporary from parameters and execute ZIP................
for %%a in (x X) do if "%1"==".%%a" %0 .sub2 %0 %2 %3 %4 %5 %6 %7 %8
for %%a in (x X) do if "%2"==".%%a" %0 .sub2 %0 %1 %3 %4 %5 %6 %7 %8
for %%a in (x X) do if "%3"==".%%a" %0 .sub2 %0 %1 %2 %4 %5 %6 %7 %8
for %%a in (x X) do if "%4"==".%%a" %0 .sub2 %0 %1 %2 %3 %5 %6 %7 %8
for %%a in (x X) do if "%5"==".%%a" %0 .sub2 %0 %1 %2 %3 %4 %6 %7 %8
for %%a in (x X) do if "%6"==".%%a" %0 .sub2 %0 %1 %2 %3 %4 %5 %7 %8
for %%a in (x X) do if "%7"==".%%a" %0 .sub2 %0 %1 %2 %3 %4 %5 %6 %8
for %%a in (x X) do if "%8"==".%%a" %0 .sub2 %0 %1 %2 %3 %4 %5 %6 %7
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 end
:error3
echo *** An error occurred while sending $DIRLIST.BAT, $FILLIST.BAT and $FILSPEC.BAT
echo (see above)
goto recover1
: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" %0 .sub4 %0 %1 %2 %4 %5 %6 %7 %8 %9
for %%a in (x X) do if "%4"==".%%a" %0 .sub4 %0 %1 %2 %3 %5 %6 %7 %8 %9
for %%a in (x X) do if "%5"==".%%a" %0 .sub4 %0 %1 %2 %3 %4 %6 %7 %8 %9
for %%a in (x X) do if "%6"==".%%a" %0 .sub4 %0 %1 %2 %3 %4 %5 %7 %8 %9
for %%a in (x X) do if "%7"==".%%a" %0 .sub4 %0 %1 %2 %3 %4 %5 %6 %8 %9
for %%a in (x X) do if "%8"==".%%a" %0 .sub4 %0 %1 %2 %3 %4 %5 %6 %7 %9
for %%a in (x X) do if "%9"==".%%a" %0 .sub4 %0 %1 %2 %3 %4 %5 %6 %7 %8
%0 .entry2 %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
rem never pass here!
: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