Changeset 1090 for palm/trunk/SCRIPTS/batch_scp
- Timestamp:
- Feb 2, 2013 7:06:13 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
palm/trunk/SCRIPTS/batch_scp
r693 r1090 1 1 #! /bin/ksh 2 # batch_scp - Shellskript Version: @(#)batch_scp 1.0a 25/10/05 2 3 # batch_scp - script for automatic file/directory transfer using scp 4 5 #--------------------------------------------------------------------------------# 6 # This file is part of PALM. 7 # 8 # PALM is free software: you can redistribute it and/or modify it under the terms 9 # of the GNU General Public License as published by the Free Software Foundation, 10 # either version 3 of the License, or (at your option) any later version. 11 # 12 # PALM is distributed in the hope that it will be useful, but WITHOUT ANY 13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details. 15 # 16 # You should have received a copy of the GNU General Public License along with 17 # PALM. If not, see <http://www.gnu.org/licenses/>. 18 # 19 # Copyright 1997-2012 Leibniz University Hannover 20 #--------------------------------------------------------------------------------# 21 # 22 # Current revisions: 23 # ------------------ 24 # code put under GPL (PALM 3.9) 25 # adjustments for Kyushu-University computing center (lckyut) 26 # old changelog messages removed 27 # 28 # Former revisions: 29 # ----------------- 3 30 # $Id$ 4 5 # Prozedur zum automatischen Transfer von Dateien mittels scp 6 # 7 # batch_scp hat 4 Argumente: 8 # $1 = IP-Adresse des Zielrechners 9 # $2 = zu uebertragende Datei 10 # $3 = Verzeichnis, in das kopiert werden soll 11 # $4 = Dateiname der Zieldatei 12 13 14 # ACHTUNG!!!!!!!! 15 # 16 # batch_scp hat noch folgenden grossen Mangel: wenn die Verzeichnisse 17 # auf den jeweiligen Remote-Rechnern aeltere Dateien beinhalten, 18 # die beim "ls -al" eine Jahreszahl und keine Uhrzeit (aa:bb) liefern, 19 # dann kann batch_scp die Dateinamen nicht ueberpruefen und findet 20 # z.B. bei -g die entsprechende Datei nicht! 21 # 22 # 23 24 25 # letzte Aenderung: 26 # 29/11/01 - Siggi - Entwicklungsbeginn 27 # 04/01/02 - Siggi - Version 1.0 funktionsfaehig 28 # 15/02/02 - Siggi - Verzeichnis-Listing umgestellt von "ls -al" auf "ls -1" 29 # 30/05/02 - Siggi - Abbruch mit exit 1 bei scp- oder ssh-Fehler 30 # 12/06/02 - Siggi - Version 1.0a, parent directories are also created, if 31 # directory on remote host does not exist 32 # 18/09/02 - Siggi - Fehlerabfragen korrigiert (waren wegen Klammerung 33 # unwirksam) 34 # 12/03/03 - Siggi - errfile and filelist are not stored in /tmp any more 35 # errors in execution of ssh does not lead 36 # to an abort on the NEC-system at DKRZ 37 # 01/04/03 - Siggi - small error concerning creation of catalogs removed 38 # 23/01/04 - Siggi - additional test output for scp on hurrikan 39 # 02/12/04 - Siggi - additional check of file size on remote host after scp. 40 # If the file sizes on local and remote host are equal, 41 # the scp exit status is ignored 42 # 03/12/04 - Siggi - additional checks of ssh actions independent of the 43 # ssh exit status 44 # 11/03/05 - Siggi - arguments are output in case of error exit 45 # 25/10/05 - Siggi - put of catalogs realized 46 # 27/04/09 - Marcus- use option -p for all scp calls 47 # 08/03/11 - Siggi - adjustments for ibmkisti: this machine allows 48 # outgoing ssh/scp connections only from the 49 # interactive nodes (gaiad). All ssh/scp traffic is 50 # done via this interactive node. 31 # 32 # 08/03/11 - Siggi - adjustments for ibmkisti: this machine allows 33 # outgoing ssh/scp connections only from the 34 # interactive nodes (gaiad). All ssh/scp traffic is 35 # done via this interactive node. 36 # 04/01/02 - Siggi - first version finished 37 # 29/11/01 - Siggi - script development started 38 # 39 #--------------------------------------------------------------------------------# 40 # batch_scp - script for automatic file/directory transfers using scp 41 # 42 # batch_scp has 4 arguments: 43 # $1 = IP-addres of remote (target) machine 44 # $2 = file to be transferred 45 # $3 = directory of remote machine, where file should be copied to 46 # $4 = filename that file should be given on remote machine 47 # 48 # ATTENTION: problems might occur if directories on remote machine include very 49 # old files for which "ls -al" does give "year" as modification 50 # time instead of "hh:mm". In such a case, batch_scp cannot check the 51 # filename and may not find the file (e.g. if option -g is used). 52 #--------------------------------------------------------------------------------# 51 53 52 54 … … 60 62 check=false 61 63 delete=false 62 errfile= ftpcopy.errfile.$random64 errfile=batch_scp.errfile.$random 63 65 filelist=filelist.$random 64 66 get=false … … 81 83 trap 'if [[ $locat != normal ]] 82 84 then 83 cat $filelist $errfile 85 [[ -f "$filelist" ]] && cat $filelist 86 [[ -f "$errfile" ]] && cat $errfile 84 87 rm -rf $filelist $errfile 85 88 printf " +++ BATCH_SCP terminated \n" … … 296 299 ssh $local_user@gaiad "ssh $1 -l $remote_user \"cd $3; ls -1; echo '*** list complete'\" " > $filelist 2>&1 297 300 else 298 ssh $1 -l $remote_user "cd $3; ls -1; echo '*** list complete'" > $filelist 2>&1301 ssh -p 22 $1 -l $remote_user "cd $3; ls -1; echo '*** list complete'" > $filelist 2>&1 299 302 fi 300 303 ssh_status=$? … … 506 509 ssh $local_user@gaiad "ssh $1 -l $remote_user \"cd $3\" " > $filelist 507 510 else 508 ssh $1 - l $remote_user "cd $3" > $filelist511 ssh $1 -p 22 -l $remote_user "cd $3" > $filelist 509 512 fi 510 513 if [[ $? != 0 ]] … … 569 572 if [[ $catalog_copy = false ]] 570 573 then 571 scp - p $2 $remote_user@$1:$catalog_name$4$zyklusnr > /dev/null574 scp -P 22 -p $2 $remote_user@$1:$catalog_name$4$zyklusnr > /dev/null 572 575 else 573 scp - p -r $2 $remote_user@$1:$catalog_name$4$zyklusnr > /dev/null576 scp -P 22 -p -r $2 $remote_user@$1:$catalog_name$4$zyklusnr > /dev/null 574 577 fi 575 578 fi … … 587 590 remote_size=`ssh $local_user@gaiad "ssh $1 -l $remote_user \"ls -al $catalog_name$4$zyklusnr\" "` 588 591 else 589 remote_size=`ssh $1 - l $remote_user "ls -al $catalog_name$4$zyklusnr"`592 remote_size=`ssh $1 -p 22 -l $remote_user "ls -al $catalog_name$4$zyklusnr"` 590 593 fi 591 594 remote_size=`echo $remote_size | cut -d" " -f5` … … 604 607 ssh $local_user@gaiad "cd $local_wdir; scp -p $2 $remote_user@$1:${catalog_name}batch_scp_append_file.$random" > /dev/null 605 608 else 606 scp - p $2 $remote_user@$1:${catalog_name}batch_scp_append_file.$random > /dev/null609 scp -P 22 -p $2 $remote_user@$1:${catalog_name}batch_scp_append_file.$random > /dev/null 607 610 fi 608 611 if [[ $? != 0 ]] … … 617 620 remote_size=`ssh $local_user@gaiad "ssh $1 -l $remote_user \"ls -al ${catalog_name}batch_scp_append_file.$random\" "` 618 621 else 619 remote_size=`ssh $1 - l $remote_user "ls -al ${catalog_name}batch_scp_append_file.$random"`622 remote_size=`ssh $1 -p 22 -l $remote_user "ls -al ${catalog_name}batch_scp_append_file.$random"` 620 623 fi 621 624 remote_size=`echo $remote_size | cut -d" " -f5` … … 636 639 ssh $local_user@gaiad "ssh $1 -l $remote_user \"cd $3; cat batch_scp_append_file.$random >> $4$zyklusnr; rm batch_scp_append_file.$random; echo '*** append complete'\" " > $filelist 637 640 else 638 ssh $1 - l $remote_user "cd $3; cat batch_scp_append_file.$random >> $4$zyklusnr; rm batch_scp_append_file.$random; echo '*** append complete'" > $filelist641 ssh $1 -p 22 -l $remote_user "cd $3; cat batch_scp_append_file.$random >> $4$zyklusnr; rm batch_scp_append_file.$random; echo '*** append complete'" > $filelist 639 642 fi 640 643 if [[ $? != 0 ]] … … 656 659 ssh $local_user@gaiad "ssh $1 -l $remote_user \"mkdir -p $3\" " 657 660 else 658 ssh $1 - l $remote_user "mkdir -p $3"661 ssh $1 -p 22 -l $remote_user "mkdir -p $3" 659 662 fi 660 663 if [[ $? != 0 ]] … … 666 669 ssh $local_user@gaiad "cd $local_wdir; scp -p $2 $remote_user@$1:$catalog_name$4$zyklusnr" > /dev/null 667 670 else 668 scp - p $2 $remote_user@$1:$catalog_name$4$zyklusnr > /dev/null671 scp -P 22 -p $2 $remote_user@$1:$catalog_name$4$zyklusnr > /dev/null 669 672 fi 670 673 if [[ $? != 0 ]] … … 690 693 ssh $local_user@gaiad "cd $local_wdir; scp -p $remote_user@$1:$catalog_name$4$zyklusnr $2" > /dev/null 691 694 else 692 scp - p $remote_user@$1:$catalog_name$4$zyklusnr $2 > /dev/null695 scp -P 22 -p $remote_user@$1:$catalog_name$4$zyklusnr $2 > /dev/null 693 696 fi 694 697 if [[ $? != 0 ]]
Note: See TracChangeset
for help on using the changeset viewer.