Ignore:
Timestamp:
Feb 2, 2013 7:06:13 AM (9 years ago)
Author:
raasch
Message:

script adjustments for Kyushu-University computing center (lckyut)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SCRIPTS/batch_scp

    r693 r1090  
    11#! /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# -----------------
    330# $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#--------------------------------------------------------------------------------#
    5153
    5254
     
    6062 check=false
    6163 delete=false
    62  errfile=ftpcopy.errfile.$random
     64 errfile=batch_scp.errfile.$random
    6365 filelist=filelist.$random
    6466 get=false
     
    8183 trap 'if [[ $locat != normal ]]
    8284       then
    83           cat $filelist $errfile
     85          [[ -f "$filelist" ]]  &&  cat $filelist
     86          [[ -f "$errfile"  ]]  &&  cat $errfile
    8487          rm -rf $filelist $errfile
    8588          printf " +++ BATCH_SCP terminated \n"
     
    296299    ssh $local_user@gaiad "ssh $1 -l $remote_user \"cd $3; ls -1; echo '*** list complete'\" "  > $filelist  2>&1
    297300 else
    298     ssh $1 -l $remote_user "cd $3; ls -1; echo '*** list complete'" > $filelist  2>&1
     301    ssh -p 22 $1 -l $remote_user "cd $3; ls -1; echo '*** list complete'" > $filelist  2>&1
    299302 fi
    300303 ssh_status=$?
     
    506509       ssh $local_user@gaiad "ssh $1 -l $remote_user \"cd $3\" " > $filelist
    507510    else
    508        ssh $1 -l $remote_user "cd $3" > $filelist
     511       ssh $1 -p 22 -l $remote_user "cd $3" > $filelist
    509512    fi
    510513    if [[ $? != 0 ]]
     
    569572             if [[ $catalog_copy = false ]]
    570573             then
    571                 scp -p $2 $remote_user@$1:$catalog_name$4$zyklusnr  > /dev/null
     574                scp -P 22 -p $2 $remote_user@$1:$catalog_name$4$zyklusnr  > /dev/null
    572575             else
    573                 scp -p -r $2 $remote_user@$1:$catalog_name$4$zyklusnr  > /dev/null
     576                scp -P 22 -p -r $2 $remote_user@$1:$catalog_name$4$zyklusnr  > /dev/null
    574577             fi
    575578          fi
     
    587590                remote_size=`ssh $local_user@gaiad "ssh $1 -l $remote_user \"ls -al $catalog_name$4$zyklusnr\" "`
    588591             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"`
    590593             fi
    591594             remote_size=`echo $remote_size | cut -d" " -f5`
     
    604607             ssh $local_user@gaiad "cd $local_wdir; scp -p $2 $remote_user@$1:${catalog_name}batch_scp_append_file.$random"  > /dev/null
    605608          else
    606              scp -p $2 $remote_user@$1:${catalog_name}batch_scp_append_file.$random  > /dev/null
     609             scp -P 22 -p $2 $remote_user@$1:${catalog_name}batch_scp_append_file.$random  > /dev/null
    607610          fi
    608611          if [[ $? != 0 ]]
     
    617620                remote_size=`ssh $local_user@gaiad "ssh $1 -l $remote_user \"ls -al ${catalog_name}batch_scp_append_file.$random\" "`
    618621             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"`
    620623             fi
    621624             remote_size=`echo $remote_size | cut -d" " -f5`
     
    636639             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
    637640          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'" > $filelist
     641             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
    639642          fi
    640643          if [[ $? != 0 ]]
     
    656659          ssh $local_user@gaiad "ssh $1 -l $remote_user \"mkdir -p $3\" "
    657660       else
    658           ssh $1 -l $remote_user "mkdir -p $3"
     661          ssh $1 -p 22 -l $remote_user "mkdir -p $3"
    659662       fi
    660663       if [[ $? != 0 ]]
     
    666669          ssh $local_user@gaiad "cd $local_wdir; scp -p $2 $remote_user@$1:$catalog_name$4$zyklusnr"  > /dev/null
    667670       else
    668           scp -p $2 $remote_user@$1:$catalog_name$4$zyklusnr  > /dev/null
     671          scp -P 22 -p $2 $remote_user@$1:$catalog_name$4$zyklusnr  > /dev/null
    669672       fi
    670673       if [[ $? != 0 ]]
     
    690693             ssh $local_user@gaiad "cd $local_wdir; scp -p $remote_user@$1:$catalog_name$4$zyklusnr $2"  > /dev/null
    691694          else
    692              scp -p $remote_user@$1:$catalog_name$4$zyklusnr $2  > /dev/null
     695             scp -P 22 -p $remote_user@$1:$catalog_name$4$zyklusnr $2  > /dev/null
    693696          fi
    694697          if [[ $? != 0 ]]
Note: See TracChangeset for help on using the changeset viewer.