Changeset 2261 for palm/trunk/SCRIPTS/batch_scp
- Timestamp:
- Jun 8, 2017 2:25:57 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SCRIPTS/batch_scp
r1310 r2261 1 #! /bin/ ksh1 #! /bin/bash 2 2 3 3 # batch_scp - script for automatic file/directory transfer using scp … … 22 22 # Current revisions: 23 23 # ------------------ 24 # 25 # 24 # 25 # 26 26 # Former revisions: 27 27 # ----------------- 28 28 # $Id$ 29 # option usecycle added, script is running under bash now, 30 # filenames are allowed to contain arbitrary number of dots "." 31 # 32 # 1310 2014-03-14 08:01:56Z raasch 29 33 # 30 34 # 1202 2013-07-10 16:22:07Z witha … … 52 56 # batch_scp - script for automatic file/directory transfers using scp 53 57 # 54 # batch_scp has 4 arguments:58 # batch_scp has up to 5 arguments (first 4 are mandatory): 55 59 # $1 = IP-addres of remote (target) machine 56 60 # $2 = file to be transferred 57 61 # $3 = directory of remote machine, where file should be copied to 58 62 # $4 = filename that file should be given on remote machine 63 # $5 = file extension (optional argument) 59 64 # 60 65 # ATTENTION: problems might occur if directories on remote machine include very … … 89 94 transfermode=binary 90 95 zyklusnr="" 91 typeset -i iii icycle maxcycle=0 wait=096 typeset -i iii icycle maxcycle=0 usecycle wait=0 92 97 93 98 # FEHLERBEHANDLUNG … … 113 118 114 119 # SHELLSCRIPT-OPTIONEN EINLESEN 115 while getopts :aAbcCdgmnoP:qsu: w: option120 while getopts :aAbcCdgmnoP:qsu:U:w: option 116 121 do 117 122 case $option in … … 130 135 (s) silent=true;; 131 136 (u) remote_user=$OPTARG;; 137 (U) usecycle=$OPTARG;; 132 138 (w) wait=$OPTARG;; 133 139 (\?) printf " +++ option $OPTARG unknown \n" … … 136 142 esac 137 143 done 138 shift OPTIND-1 144 145 (( to_shift = $OPTIND - 1 )) 146 shift $to_shift 147 139 148 140 149 … … 144 153 then 145 154 (printf "\n *** batch_scp can be called as follows:\n" 146 printf "\n batch_scp -a -b -d -g -o -q -s -u.. - w.. <param1> <param2> <param3> <param4>\n"155 printf "\n batch_scp -a -b -d -g -o -q -s -u.. -U.. -w.. <param1> <param2> <param3> <param4>\n" 147 156 printf "\n Description of available options:\n" 148 157 printf "\n Option Description Default-Value" … … 163 172 printf "\n -s do not display informative messages ---" 164 173 printf "\n -u username on remote machine <username>" 174 printf "\n -U cycle number to be used ---" 165 175 printf "\n -w waiting time in seconds, before trans- 0" 166 176 printf "\n fer will be initiated" … … 226 236 227 237 228 # DATEINAME IM 4. ARGUMENT DARF NUR BEIM UEBERSCHREIBEN ODER IM ABSOLUT-229 # MODUS PUNKTE ENTHALTEN230 if [[ $overwrite = false && $absolut = false && $(echo $4 | grep -c "\.") != 0 ]]231 then232 printf " +++ 4th argument may only contain dots (".") , if one of the \n"233 printf " options -a or -o are given \n"234 locat=argument; exit235 fi236 237 238 238 # QUOTE WAIT FUNKTIONIERT NICHT BEIM KOPIEREN GANZER VERZEICHNISSE 239 239 if [[ $quote_wait = true && $catalog_copy = true ]] … … 386 386 if [[ $absolut = false ]] 387 387 then 388 text=$(echo $zeile | cut -f1 -d".") 389 if [[ "$text" = "$4" ]] 390 then 391 found=true 392 cycle=$(echo $zeile | cut -f2 -d".") 393 if [[ "$cycle" = "$text" ]] 394 then 388 # REMOVE EXTENSION, IF EXISTING AND GIVEN AS ARGUMENT 389 if [[ "$5" != "" && "$5" != " " ]] 390 then 391 extension=${zeile##*.} 392 if [[ $extension = $5 ]] 393 then 394 text=${zeile%.*} 395 else 396 text=${zeile} 397 fi 398 else 399 text=${zeile} 400 fi 401 402 # GET AND REMOVE CYCLE NUMBER, IF EXISTING, AND CHECK, IF FILE EXISTS 403 cycle=${text##*.} 404 if [[ $cycle = $text ]] 405 then 406 # filename contains no dot, i.e. no cycle number 407 if [[ "$text" = "$4" ]] 408 then 409 found=true 395 410 (( icycle = 0 )) 396 else 397 398 # PRUEFEN, OB CYCLE EINE ZAHL IST 399 (( iii = 1 )) 400 character=`echo $cycle | cut -c$iii` 401 character_found=false 402 while [[ "$character" != "" && $character_found = false ]] 403 do 404 case $character in 405 (0|1|2|3|4|5|6|7|8|9) true;; 406 (*) character_found=true 407 esac 408 (( iii = iii + 1 )) 409 character=`echo $cycle | cut -c$iii` 410 done 411 412 if [[ $character_found = false ]] 411 fi 412 else 413 # filename contains at least one dot 414 # find out if the string after the last dot is a number 415 if [[ $cycle =~ ^-?[0-9]+$ ]] 416 then 417 text=${text%.*} 418 if [[ "$text" = "$4" ]] 413 419 then 420 found=true 414 421 (( icycle = $cycle )) 415 422 fi 416 fi >|$errfile 2>&1 # AUSGABE FEHLER AUF ERRFILE WENN CYCLE NICHTNUMERISCH 417 418 419 # INFORMATIVE AUSGABE, WENN DATEI NICHTNUMERISCHE EXTENSION HAT 420 # if [[ $(cat $errfile | grep -c "bad number") != 0 ]] 421 if [[ $character_found = true ]] 422 then 423 if [[ $cycle != "$5" ]] 423 else 424 if [[ "$text" = "$4" ]] 424 425 then 425 printf " +++ file \"$text\" has non-numerical extension \".$cycle\" \n" 426 locat=file; exit 427 else 428 if [[ $silent = false ]] 429 then 430 printf " >>> file \"$text\" has non-numerical extension \".$cycle\" \n" 431 fi 426 found=true 427 (( icycle = 0 )) 432 428 fi 433 429 fi 430 fi 431 432 433 # text=$(echo $zeile | cut -f1 -d".") 434 # 435 # if [[ "$text" = "$4" ]] 436 # then 437 # found=true 438 # cycle=$(echo $zeile | cut -f2 -d".") 439 # if [[ "$cycle" = "$text" ]] 440 # then 441 # (( icycle = 0 )) 442 # else 443 # 444 # # PRUEFEN, OB CYCLE EINE ZAHL IST 445 # (( iii = 1 )) 446 # character=`echo $cycle | cut -c$iii` 447 # character_found=false 448 # while [[ "$character" != "" && $character_found = false ]] 449 # do 450 # case $character in 451 # (0|1|2|3|4|5|6|7|8|9) true;; 452 # (*) character_found=true 453 # esac 454 # (( iii = iii + 1 )) 455 # character=`echo $cycle | cut -c$iii` 456 # done 457 # 458 # if [[ $character_found = false ]] 459 # then 460 # (( icycle = $cycle )) 461 # fi 462 # fi >|$errfile 2>&1 # AUSGABE FEHLER AUF ERRFILE WENN CYCLE NICHTNUMERISCH 463 # 464 # 465 # # INFORMATIVE AUSGABE, WENN DATEI NICHTNUMERISCHE EXTENSION HAT 466 # # if [[ $(cat $errfile | grep -c "bad number") != 0 ]] 467 # if [[ $character_found = true ]] 468 # then 469 # if [[ $cycle != "$5" ]] 470 # then 471 # printf " +++ file \"$text\" has non-numerical extension \".$cycle\" \n" 472 # locat=file; exit 473 # else 474 # if [[ $silent = false ]] 475 # then 476 # printf " >>> file \"$text\" has non-numerical extension \".$cycle\" \n" 477 # fi 478 # fi 479 # fi 434 480 435 481 if (( icycle > maxcycle )) … … 437 483 (( maxcycle = icycle )) 438 484 fi 439 fi485 # fi 440 486 441 487 else … … 458 504 then 459 505 (( maxcycle = maxcycle + 1 )) 506 # TRY TO USE FIXED CYCLE NUMBER, IF GIVEN AS OPTION 507 if [[ "$usecycle" != "" ]] 508 then 509 if (( usecycle >= maxcycle )) 510 then 511 (( maxcycle = usecycle )) 512 else 513 printf " >>> Unfied cycle number cannot be used\n" 514 fi 515 fi 460 516 zyklusnr=".$maxcycle" 461 517 else … … 489 545 fi 490 546 fi 547 491 548 else 492 zyklusnr="" 549 550 if [[ "$usecycle" != "" ]] 551 then 552 (( maxcycle = usecycle )) 553 zyklusnr=".$usecycle" 554 else 555 zyklusnr="" 556 fi 493 557 494 558 # ABBRUCH, WENN DATEI VON ZIELRECHNER GEHOLT WERDEN SOLL, DORT ABER
Note: See TracChangeset
for help on using the changeset viewer.