Changeset 2600 for palm/trunk/SCRIPTS/batch_scp
- Timestamp:
- Nov 1, 2017 2:11:20 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SCRIPTS/batch_scp
r2261 r2600 27 27 # ----------------- 28 28 # $Id$ 29 # cycle numbers made three digits wide 30 # host depending code completely removed 31 # 32 # 2261 2017-06-08 14:25:57Z raasch 29 33 # option usecycle added, script is running under bash now, 30 34 # filenames are allowed to contain arbitrary number of dots "." … … 78 82 catalog_copy=false 79 83 check=false 84 cyclestring="" 80 85 delete=false 81 86 errfile=batch_scp.errfile.$random … … 83 88 get=false 84 89 local_host=`hostname` 85 local_user=$USER86 90 local_wdir=`pwd` 87 91 locat=normal … … 93 97 silent=false 94 98 transfermode=binary 95 zyklusnr=""96 99 typeset -i iii icycle maxcycle=0 usecycle wait=0 97 100 … … 261 264 262 265 263 # Using absolute paths for ssh on lcflow (nodes "cfd_*") as the paths of the264 # job scheduler have changed265 if [[ $(echo $local_host | cut -c1-3) = "cfd" ]]266 then267 SSH_BIN=/usr/bin/ssh268 else269 SSH_BIN=ssh270 fi271 272 273 266 # PRUEFEN, OB LOKALE DATEI/LOKALES VERZEICHNIS VORHANDEN BZW. NICHT VORHANDEN 274 267 if [[ $get = false ]] … … 326 319 327 320 # VERZEICHNISLSTE DES ZIELRECHNERS ERSTELLEN 328 if [[ $(echo $local_host | cut -c1-4) = gaia ]] 329 then 330 ssh $SSH_PORTOPT $local_user@gaiad "ssh $SSH_PORTOPT $1 -l $remote_user \"unset LANG; cd $3; ls -1; echo '*** list complete'\" " > $filelist 2>&1 331 else 332 $SSH_BIN $SSH_PORTOPT $1 -l $remote_user "unset LANG; cd $3; ls -1; echo '*** list complete'" > $filelist 2>&1 333 fi 321 ssh $SSH_PORTOPT $1 -l $remote_user "unset LANG; cd $3; ls -1; echo '*** list complete'" > $filelist 2>&1 334 322 ssh_status=$? 335 323 … … 430 418 fi 431 419 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 480 481 if (( icycle > maxcycle )) 482 then 483 (( maxcycle = icycle )) 484 fi 485 # fi 420 if (( icycle > maxcycle )) 421 then 422 (( maxcycle = icycle )) 423 424 # FOR COMPATIBILITY REASONS WITH OLDER VERSIONS 425 # CHECK IF CYCLE NUMBER CONTAINS LEADING ZEROS 426 if [[ $(echo $cycle | cut -c1) = 0 ]] 427 then 428 leading_zero=true 429 else 430 leading_zero=false 431 fi 432 fi 486 433 487 434 else … … 504 451 then 505 452 (( maxcycle = maxcycle + 1 )) 453 506 454 # TRY TO USE FIXED CYCLE NUMBER, IF GIVEN AS OPTION 507 455 if [[ "$usecycle" != "" ]] … … 514 462 fi 515 463 fi 516 zyklusnr=".$maxcycle"464 cyclestring=`printf ".%03d" $maxcycle` 517 465 else 518 466 if (( maxcycle == 0 )) 519 467 then 520 zyklusnr=""468 cyclestring="" 521 469 else 522 zyklusnr=".$maxcycle"470 cyclestring=`printf ".%03d" $maxcycle` 523 471 fi 524 472 fi … … 536 484 if (( maxcycle == 0 )) 537 485 then 538 zyklusnr=""486 cyclestring="" 539 487 else 540 zyklusnr=".$maxcycle" 488 489 # MAKE CYCLE NUMBER THREE DIGITS WIDE 490 if [[ $leading_zero = true ]] 491 then 492 cyclestring=`printf ".%03d" $maxcycle` 493 else 494 cyclestring=.$maxcycle 495 fi 541 496 (( maxcycle = 0 )) 542 497 fi 543 498 else 544 zyklusnr=""499 cyclestring="" 545 500 fi 546 501 fi … … 551 506 then 552 507 (( maxcycle = usecycle )) 553 zyklusnr=".$usecycle"508 cyclestring=`printf ".%03d" $usecycle` 554 509 else 555 zyklusnr=""510 cyclestring="" 556 511 fi 557 512 … … 571 526 if [[ $make_catalog = force ]] 572 527 then 573 zyklusnr=""528 cyclestring="" 574 529 (( maxcycle = 0 )) 575 530 fi … … 580 535 if [[ $print_local_filename = true ]] 581 536 then 582 printf "$4$ zyklusnr\n"537 printf "$4$cyclestring\n" 583 538 rm -r $filelist 584 539 exit … … 591 546 if [[ "$5" != "" && $get = false ]] 592 547 then 593 zyklusnr=${zyklusnr}.$5548 cyclestring=${cyclestring}.$5 594 549 fi 595 550 … … 599 554 if [[ $catalog_copy = true && $get = true ]] 600 555 then 556 601 557 rm -rf $filelist 602 if [[ $(echo $local_host | cut -c1-4) = gaia ]] 603 then 604 ssh $SSH_PORTOPT $local_user@gaiad "ssh $1 -l $remote_user \"cd $3\" " > $filelist 605 else 606 $SSH_BIN $SSH_PORTOPT $1 -l $remote_user "cd $3" > $filelist 607 fi 558 ssh $SSH_PORTOPT $1 -l $remote_user "cd $3" > $filelist 559 608 560 if [[ $? != 0 ]] 609 561 then … … 616 568 locat=directory; exit 617 569 fi 570 618 571 fi 619 572 … … 630 583 631 584 632 # Auf IBM-Rechnern (HLRN) Tilde aus Katalognamen entfernen, da scp633 # diese nicht versteht634 585 catalog_name=$3 635 if [[ $(hostname | cut -c1-4) = hreg || $(hostname | cut -c1-4) = breg ]]636 then637 catalog_name=${catalog_name#"~/"}638 catalog_name=${catalog_name#"~"}639 fi640 586 [[ "$catalog_name" != "" ]] && catalog_name=${catalog_name}/ 641 587 … … 648 594 if [[ $append = false ]] 649 595 then 650 if [[ $(echo $local_host | cut -c1-2) = cs ]] 651 then 652 if [[ $catalog_copy = false ]] 653 then 654 scp $PORTOPT -p -q -v $2 $remote_user@$1:$catalog_name$4$zyklusnr 655 else 656 scp $PORTOPT -p -r -q -v $2 $remote_user@$1:$catalog_name$4$zyklusnr 657 fi 658 elif [[ $(echo $local_host | cut -c1-4) = gaia ]] 659 then 660 if [[ $catalog_copy = false ]] 661 then 662 ssh $SSH_PORTOPT $local_user@gaiad "cd $local_wdir; scp $PORTOPT -p $2 $remote_user@$1:$catalog_name$4$zyklusnr" > /dev/null 663 else 664 ssh $SSH_PORTOPT $local_user@gaiad "cd $local_wdir; scp $PORTOPT -p -r $2 $remote_user@$1:$catalog_name$4$zyklusnr" > /dev/null 665 fi 596 597 if [[ $catalog_copy = false ]] 598 then 599 scp $PORTOPT -p $2 $remote_user@$1:$catalog_name$4$cyclestring > /dev/null 666 600 else 667 if [[ $catalog_copy = false ]] 668 then 669 scp $PORTOPT -p $2 $remote_user@$1:$catalog_name$4$zyklusnr > /dev/null 670 else 671 scp $PORTOPT -p -r $2 $remote_user@$1:$catalog_name$4$zyklusnr > /dev/null 672 fi 601 scp $PORTOPT -p -r $2 $remote_user@$1:$catalog_name$4$cyclestring > /dev/null 673 602 fi 674 603 scp_status=$? … … 681 610 local_size=`echo $local_size | cut -d" " -f5` 682 611 683 if [[ $(echo $local_host | cut -c1-4) = gaia ]] 684 then 685 remote_size=`ssh $SSH_PORTOPT $local_user@gaiad "ssh $SSH_PORTOPT $1 -l $remote_user \"ls -al $catalog_name$4$zyklusnr\" "` 686 else 687 remote_size=`$SSH_BIN $SSH_PORTOPT $1 -l $remote_user "ls -al $catalog_name$4$zyklusnr"` 688 fi 612 remote_size=`ssh $SSH_PORTOPT $1 -l $remote_user "ls -al $catalog_name$4$cyclestring"` 689 613 remote_size=`echo $remote_size | cut -d" " -f5` 690 614 … … 697 621 fi 698 622 fi 699 else 700 if [[ $(echo $local_host | cut -c1-4) = gaia ]] 701 then 702 ssh $SSH_PORTOPT $local_user@gaiad "cd $local_wdir; scp $PORTOPT -p $2 $remote_user@$1:${catalog_name}batch_scp_append_file.$random" > /dev/null 703 else 704 scp $PORTOPT -p $2 $remote_user@$1:${catalog_name}batch_scp_append_file.$random > /dev/null 705 fi 623 624 else 625 626 scp $PORTOPT -p $2 $remote_user@$1:${catalog_name}batch_scp_append_file.$random > /dev/null 627 706 628 if [[ $? != 0 ]] 707 629 then … … 711 633 local_size=`echo $local_size | cut -d" " -f5` 712 634 713 if [[ $(echo $local_host | cut -c1-4) = gaia ]] 714 then 715 remote_size=`ssh $SSH_PORTOPT $local_user@gaiad "ssh $SSH_PORTOPT $1 -l $remote_user \"ls -al ${catalog_name}batch_scp_append_file.$random\" "` 716 else 717 remote_size=`$SSH_BIN $SSH_PORTOPT $1 -l $remote_user "ls -al ${catalog_name}batch_scp_append_file.$random"` 718 fi 635 remote_size=`ssh $SSH_PORTOPT $1 -l $remote_user "ls -al ${catalog_name}batch_scp_append_file.$random"` 719 636 remote_size=`echo $remote_size | cut -d" " -f5` 720 637 … … 730 647 rm $filelist 731 648 732 if [[ $(echo $local_host | cut -c1-4) = gaia ]] 733 then 734 ssh $SSH_PORTOPT $local_user@gaiad "ssh $SSH_PORTOPT $1 -l $remote_user \"cd $3; cat batch_scp_append_file.$random >> $4$zyklusnr; rm batch_scp_append_file.$random; echo '*** append complete'\" " > $filelist 735 else 736 $SSH_BIN $SSH_PORTOPT $1 -l $remote_user "cd $3; cat batch_scp_append_file.$random >> $4$zyklusnr; rm batch_scp_append_file.$random; echo '*** append complete'" > $filelist 737 fi 649 ssh $SSH_PORTOPT $1 -l $remote_user "cd $3; cat batch_scp_append_file.$random >> $4$cyclestring; rm batch_scp_append_file.$random; echo '*** append complete'" > $filelist 650 738 651 if [[ $? != 0 ]] 739 652 then … … 749 662 fi 750 663 fi 664 751 665 else 752 if [[ $(echo $local_host | cut -c1-4) = gaia ]] 753 then 754 ssh $SSH_PORTOPT $local_user@gaiad "ssh $1 -l $remote_user \"mkdir -p $3\" " 755 else 756 $SSH_BIN $SSH_PORTOPT $1 -l $remote_user "mkdir -p $3" 757 fi 666 667 ssh $SSH_PORTOPT $1 -l $remote_user "mkdir -p $3" 668 758 669 if [[ $? != 0 ]] 759 670 then 760 671 locat=ssh_failed_4; exit 761 672 fi 762 if [[ $(echo $local_host | cut -c1-4) = gaia ]] 763 then 764 ssh $SSH_PORTOPT $local_user@gaiad "cd $local_wdir; scp $PORTOPT -p $2 $remote_user@$1:$catalog_name$4$zyklusnr" > /dev/null 765 else 766 scp $PORTOPT -p $2 $remote_user@$1:$catalog_name$4$zyklusnr > /dev/null 767 fi 673 674 scp $PORTOPT -p $2 $remote_user@$1:$catalog_name$4$cyclestring > /dev/null 675 768 676 if [[ $? != 0 ]] 769 677 then … … 784 692 else 785 693 786 if [[ $(echo $local_host | cut -c1-4) = gaia ]] 787 then 788 ssh $SSH_PORTOPT $local_user@gaiad "cd $local_wdir; scp $PORTOPT -p $remote_user@$1:$catalog_name$4$zyklusnr $2" > /dev/null 789 else 790 scp $PORTOPT -p $remote_user@$1:$catalog_name$4$zyklusnr $2 > /dev/null 791 fi 694 scp $PORTOPT -p $remote_user@$1:$catalog_name$4$cyclestring $2 > /dev/null 695 792 696 if [[ $? != 0 ]] 793 697 then … … 796 700 797 701 fi 702 798 703 else 799 704 … … 801 706 locat=unavailable_feature; exit 802 707 803 # ftp -i $1 << %END% > /dev/null 804 #$transfermode 805 #cd $3 806 #mget * 807 #quit 808 #%END% 809 fi 708 fi 709 810 710 fi 811 711 … … 837 737 if [[ $catalog_copy = false ]] 838 738 then 839 printf " new file has cycle number $maxcycle \n"739 printf " new file has cycle number .%03d \n" $maxcycle 840 740 else 841 printf " new catalog has cycle number $maxcycle \n"842 fi 843 else 844 printf " append to cycle number $maxcycle \n"741 printf " new catalog has cycle number .%03d \n" $maxcycle 742 fi 743 else 744 printf " append to cycle number .%03d \n" $maxcycle 845 745 fi 846 746 fi
Note: See TracChangeset
for help on using the changeset viewer.