Index: palm/trunk/SCRIPTS/batch_scp
===================================================================
--- palm/trunk/SCRIPTS/batch_scp	(revision 4901)
+++ palm/trunk/SCRIPTS/batch_scp	(revision 1)
@@ -1,98 +1,50 @@
-#! /bin/bash
-
-# batch_scp - script for automatic file/directory transfer using scp
-
-#--------------------------------------------------------------------------------#
-# This file is part of the PALM model system.
-#
-# PALM is free software: you can redistribute it and/or modify it under the terms
-# of the GNU General Public License as published by the Free Software Foundation,
-# either version 3 of the License, or (at your option) any later version.
-#
-# PALM is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# PALM. If not, see <http://www.gnu.org/licenses/>.
-#
-# Copyright 1997-2021  Leibniz Universitaet Hannover
-#--------------------------------------------------------------------------------#
-#
-# Current revisions:
-# ------------------
-# 
-# 
-# Former revisions:
-# -----------------
-# $Id$
-# add cycle number to initial files too (000),
-# remove compatibility for cycle numbers which are less than three digits wide
-# 
-# 3549 2018-11-21 15:44:44Z raasch
-# english translation of german comments / variable names
-# 
-# 2718 2018-01-02 08:49:38Z maronga
-# Corrected "Former revisions" section
-# 
-# 2715 2017-12-27 11:31:43Z raasch
-# last commit documented
-# 
-# 2714 2017-12-27 11:25:57Z raasch
-# bugfix: variable cycle explicitly interpreted with 10 as the number base
-# 
-# 2696 2017-12-14 17:12:51Z kanani
-# Change in file header (GPL part)
-#
-# 2600 2017-11-01 14:11:20Z raasch
-# cycle numbers made three digits wide
-# host depending code completely removed
-# 
-# 2261 2017-06-08 14:25:57Z raasch
-# option usecycle added, script is running under bash now,
-# filenames are allowed to contain arbitrary number of dots "."
-#
-# 1310 2014-03-14 08:01:56Z raasch
-#
-# 1202 2013-07-10 16:22:07Z witha
-# adjustments for Forwind cluster (lcflow): using absolute paths for ssh
-#
-# 1099 2013-02-10 01:47:43Z raasch
-# LANG variable is unset in some ssh calls to guarantee messages in English
-#
-# 1094 2013-02-03 01:52:12Z raasch
-# new option -P for explicit setting of ssh/scp port
-#
-# 1090 2013-02-02 07:06:13Z raasch 
-# code put under GPL (PALM 3.9) 
-# adjustments for Kyushu-University computing center (lckyut)
-# old changelog messages removed
-#
-# 08/03/11 - Siggi - adjustments for ibmkisti: this machine allows
-#                    outgoing ssh/scp connections only from the
-#                    interactive nodes (gaiad). All ssh/scp traffic is
-#                    done via this interactive node.
-# 04/01/02 - Siggi - first version finished
-# 29/11/01 - Siggi - script development started
-#
-#--------------------------------------------------------------------------------#
-# batch_scp - script for automatic file/directory transfers using scp
-#
-# batch_scp has up to 5 arguments (first 4 are mandatory):
-#               $1 = IP-addres of remote (target) machine
-#               $2 = file to be transferred
-#               $3 = directory of remote machine, where file should be copied to
-#               $4 = filename that file should be given on remote machine
-#               $5 = file extension (optional argument)
-#
-# ATTENTION: problems might occur if directories on remote machine include very
-#            old files for which "ls -al" does give "year" as modification
-#            time instead of "hh:mm". In such a case, batch_scp cannot check the
-#            filename and may not find the file (e.g. if option -g is used).
-#--------------------------------------------------------------------------------#
+#! /bin/ksh
+# batch_scp - Shellskript         Version:  @(#)batch_scp 1.0a     25/10/05
+
+     # Prozedur zum automatischen Transfer von Dateien mittels scp
+     #
+     # batch_scp hat 4 Argumente:
+     #         $1 = IP-Adresse des Zielrechners
+     #         $2 = zu uebertragende Datei
+     #         $3 = Verzeichnis, in das kopiert werden soll
+     #         $4 = Dateiname der Zieldatei
+
+
+     #                 ACHTUNG!!!!!!!!
+     #
+     # batch_scp hat noch folgenden grossen Mangel: wenn die Verzeichnisse
+     # auf den jeweiligen Remote-Rechnern aeltere Dateien beinhalten,
+     # die beim "ls -al" eine Jahreszahl und keine Uhrzeit (aa:bb) liefern,
+     # dann kann batch_scp die Dateinamen nicht ueberpruefen und findet
+     # z.B. bei -g die entsprechende Datei nicht!
+     #
+     #
+
+
+     # letzte Aenderung:
+     # 29/11/01 - Siggi - Entwicklungsbeginn
+     # 04/01/02 - Siggi - Version 1.0 funktionsfaehig
+     # 15/02/02 - Siggi - Verzeichnis-Listing umgestellt von "ls -al" auf "ls -1"
+     # 30/05/02 - Siggi - Abbruch mit exit 1 bei scp- oder ssh-Fehler
+     # 12/06/02 - Siggi - Version 1.0a, parent directories are also created, if
+     #                    directory on remote host does not exist
+     # 18/09/02 - Siggi - Fehlerabfragen korrigiert (waren wegen Klammerung
+     #                    unwirksam)
+     # 12/03/03 - Siggi - errfile and filelist are not stored in /tmp any more
+     #                    errors in execution of ssh does not lead
+     #                    to an abort on the NEC-system at DKRZ
+     # 01/04/03 - Siggi - small error concerning creation of catalogs removed
+     # 23/01/04 - Siggi - additional test output for scp on hurrikan
+     # 02/12/04 - Siggi - additional check of file size on remote host after scp.
+     #                    If the file sizes on local and remote host are equal,
+     #                    the scp exit status is ignored
+     # 03/12/04 - Siggi - additional checks of ssh actions independent of the
+     #                    ssh exit status
+     # 11/03/05 - Siggi - arguments are output in case of error exit
+     # 25/10/05 - Siggi - put of catalogs realized
 
 
  
-    # VARIABLE DECLARATIONS + DEFAULT VALUES 
+    # VARIABLENVEREINBARUNGEN + DEFAULTWERTE 
  random=$RANDOM
 
@@ -101,11 +53,9 @@
  catalog_copy=false
  check=false
- cyclestring=""
  delete=false
- errfile=batch_scp.errfile.$random
+ errfile=ftpcopy.errfile.$random
  filelist=filelist.$random
  get=false
  local_host=`hostname`
- local_wdir=`pwd`
  locat=normal
  make_catalog=false
@@ -116,13 +66,12 @@
  silent=false
  transfermode=binary
- typeset -i iii icycle maxcycle=0 usecycle wait=0
-
-
-    # ERROR HANDLING IN CASE ...
-    # ... EXIT
+ zyklusnr=""
+ typeset -i iii icycle maxcycle=0 wait=0
+
+    # FEHLERBEHANDLUNG
+    # BEI EXIT:
  trap 'if [[ $locat != normal ]]
        then
-          [[ -f "$filelist" ]]  &&  cat $filelist
-          [[ -f "$errfile"  ]]  &&  cat $errfile
+          cat $filelist $errfile
           rm -rf $filelist $errfile
           printf " +++ BATCH_SCP terminated \n"
@@ -133,5 +82,5 @@
 
 
-    # ... TERMINAL-BREAK:
+    # BEI TERMINAL-BREAK:
  trap 'rm -rf $filelist $errfile
        printf " +++ BATCH_SCP terminated \n\n"
@@ -140,6 +89,6 @@
 
 
-    # READ SHELLSCRIPT-OPTIONS
- while  getopts  :aAbcCdgmnoP:qsu:U:w:  option
+    # SHELLSCRIPT-OPTIONEN EINLESEN
+ while  getopts  :aAbcCdgmnoqsu:w:  option
  do
    case  $option  in
@@ -154,9 +103,7 @@
        (n)   print_local_filename=true;;  # Option ist nicht dokumentiert !
        (o)   overwrite=true;;
-       (P)   scp_port=$OPTARG;;
        (q)   quote_wait=true;;
        (s)   silent=true;;
        (u)   remote_user=$OPTARG;;
-       (U)   usecycle=$OPTARG;;
        (w)   wait=$OPTARG;;
        (\?)  printf "  +++ option $OPTARG unknown \n"
@@ -165,16 +112,13 @@
    esac
  done
-
- (( to_shift = $OPTIND - 1 ))
- shift $to_shift
-
+ shift OPTIND-1
 
 
  
-    # LIST SHORT DESCRIPTION OF AVAILABLE OPTIONS
+    # KURZE AUFRUFBESCHREIBUNG WIRD HIER AUSGEGEBEN
  if [ "$1" = "?" ]
  then
    (printf "\n  *** batch_scp can be called as follows:\n"
-    printf "\n      batch_scp -a -b -d -g -o -q -s -u.. -U.. -w..  <param1> <param2> <param3> <param4>\n"
+    printf "\n      batch_scp -a -b -d -g -o -q -s -u.. -w..  <param1> <param2> <param3> <param4>\n"
     printf "\n      Description of available options:\n"
     printf "\n      Option  Description                            Default-Value"
@@ -195,5 +139,4 @@
     printf "\n        -s    do not display informative messages    ---"
     printf "\n        -u    username on remote machine             <username>"
-    printf "\n        -U    cycle number to be used                ---"
     printf "\n        -w    waiting time in seconds, before trans- 0"
     printf "\n              fer will be initiated"
@@ -202,5 +145,5 @@
     printf "\n      any time and have the following meaning:"
     printf "\n        <param1>  -  IP-adress of destination host"
-    printf "\n                     or \"?\"  (creates this short summary of options)"
+    printf "\n                     or \"?\"  (creates this outline)"
     printf "\n        <param2>  -  abs. or rel. path of file to be transferred"
     printf "\n        <param3>  -  directory (abs.!) on destination host. Special cahracters"
@@ -214,5 +157,5 @@
 
 
-    # CHECK FOR COMPLETENESS OF ARGUMENTS
+    # PRUEFEN, OB ALLE ARGUMENTE VORLIEGEN
  if [[ "$1" = "" ]]
  then
@@ -237,11 +180,19 @@
  if [[ -z $remote_user ]]
  then
-    printf " +++ option -u is missing \n"
-    locat=remote_user; exit
- fi
-
-
-    # APPEND IS ONLY ALLOWED FOR TRANSFER OF SINGLE FILES WITHOUT OVERWRITING
-    # IN SUCH A CASE GET IS NOT ALLOWED TOO
+
+       # PRUEFEN, OB NETRC-DATEI VORHANDEN
+    if [[ ! -f ~/.netrc ]]
+    then
+       printf " +++ option -u not given; \n"
+       printf "     getting remote-username from password file failed \n"
+       printf "     because ~/.netrc does not exist \n"
+       locat=netrc; exit
+    fi
+    grep  $1  ~/.netrc | read dum dum dum remote_user dum dum
+ fi
+
+
+    # APPEND IST NUR BEI TRANSFER EINZELNER DATEIEN OHNE UEBERSCHREIBEN
+    # ERLAUBT. GET IST DABEI EBENFALLS NICHT ERLAUBT
  if [[ $append = true  &&  ( $get = true || $catalog_copy = true || $overwrite = true ) ]]
  then
@@ -251,5 +202,15 @@
 
 
-    # QUOTE WAIT DOES NOT WORK IF COMPLETE FOLDERS ARE COPIED
+    # DATEINAME IM 4. ARGUMENT DARF NUR BEIM UEBERSCHREIBEN ODER IM ABSOLUT-
+    # MODUS PUNKTE ENTHALTEN
+ if [[ $overwrite = false  &&  $absolut = false  &&  $(echo $4 | grep -c "\.") != 0 ]]
+ then
+    printf " +++ 4th argument may only contain dots (".") , if one of the \n"
+    printf "     options -a or -o are given \n"
+    locat=argument; exit
+ fi
+
+
+    # QUOTE WAIT FUNKTIONIERT NICHT BEIM KOPIEREN GANZER VERZEICHNISSE
  if [[ $quote_wait = true  &&  $catalog_copy = true ]]
  then
@@ -259,22 +220,14 @@
 
 
-    # SCRIPT WILL BE ENDED HERE IN CASE OF CHECK-MODE
+    # IM CHECK-MODUS WIRD SCRIPT HIER BEENDET
  [[ $check = true ]]  &&  exit
 
 
-    # WAIT A BIT (MAY BE REQUIRED IN CASE OF TRANSFERS OF JOB PROTOCOLS FROM
-    # WITHIN A JOB)
+    # BESTIMMTE ZEIT WARTEN, BIS WEITERGEMACHT WIRD (NOETIG Z.B. BEI TRANSFER
+    # VON JOBPROTOKOLLEN AUS JOBS HERAUS)
  sleep  $wait
 
 
-    # SET PORT NUMBER OPTION FOR CALLS OF SSH/SCP
- if [[ "$scp_port" != "" ]]
- then
-    PORTOPT="-P $scp_port"
-    SSH_PORTOPT="-p $scp_port"
- fi
-
-
-    # CHECK, IF LOCAL FILE/FOLDER EXISTS
+    # PRUEFEN, OB LOKALE DATEI/LOKALES VERZEICHNIS VORHANDEN BZW. NICHT VORHANDEN
  if [[ $get = false ]]
  then
@@ -308,5 +261,5 @@
        else
 
-             # CHECK, IF LOCAL FILE CAN BE CREATED
+             # PRUEFEN, OB SICH LOKALE DATEI ANLEGEN LAESST
           local_dirname=`dirname $2`
           if [[ ! -d $local_dirname ]]
@@ -330,6 +283,6 @@
 
 
-    # CREATE FILE LIST OF THE TARGET HOST FOLDER
- ssh $SSH_PORTOPT $1 -l $remote_user "unset LANG; cd $3; ls -1; echo '*** list complete'" > $filelist  2>&1
+    # VERZEICHNISLSTE DES ZIELRECHNERS ERSTELLEN
+ ssh $1 -l $remote_user "cd $3; ls -1; echo '*** list complete'" > $filelist  2>&1
  ssh_status=$?
 
@@ -350,6 +303,7 @@
 
 
-    # CHECK, IF FOLDER EXISTS. A FOLDER MUST NOT EXIST, IF COMPLETE FOLDERS
-    # SHALL BE COPIED TO THE TARGET HOST
+    # PRUEFEN, OB VERZEICHNIS VORHANDEN IST. WENN GANZES VERZEICHNISS ZUM
+    # ZIELRECHNER KOPIERT WERDEN SOLL, DARF DORT NOCH KEIN ENTSPRECHENDES
+    # VERZEICHNIS VORHANDEN SEIN
  if [[ $(cat $filelist | grep -c "not found") != 0  || \
        $(cat $filelist | grep -c "No such file or directory") != 0 ]]
@@ -374,94 +328,96 @@
 
 
-    # CHECK, IF FILE/FOLDER EXISTS. IF SO, DETERMINE HIGHEST CYCLE NUMBER
-    # (OR CHECK, IN ABSOLUT-MODE, IF FILE EXSITS)
-    # BUT DO THIS IN NON-OVERWRITE-MODE ONLY
+    # PRUEFEN, OB DATEI/VERZEICHNIS VORHANDEN, WENN JA, HOECHSTEN ZYKLUS
+    # ERMITTELN (BZW. IM ABSOLUT-MODUS PRUEFEN, OB DATEI VORHANDEN IST)
+    # DAS GANZE ABER NUR, WENN NICHT OVERWRITE-MODUS GEWAEHLT WURDE, DIE
+    # EVENTUELL VORHANDENE DATEI ALSO UEBERSCHRIEBEN WERDEN SOLL
  found=false
  if [[ ( $overwrite = false   &&  $get = false )  ||  $get = true ]]
  then
-    while  read line
+    while  read zeile
     do
        if [[ $absolut = false ]]
        then
-             # REMOVE EXTENSION, IF EXISTING AND GIVEN AS ARGUMENT
-          if [[ "$5" != ""  &&  "$5" != " " ]]
-          then
-             extension=${line##*.}
-             if [[ $extension = $5 ]]
-             then
-                text=${line%.*}
+          text=$(echo $zeile | cut -f1 -d".")
+          if [[ "$text" = "$4" ]]
+          then
+             found=true
+             cycle=$(echo $zeile | cut -f2 -d".")
+             if [[ "$cycle" = "$text" ]]
+             then
+                (( icycle = 0 ))
              else
-                text=${line}
-             fi
+
+                   # PRUEFEN, OB CYCLE EINE ZAHL IST
+                (( iii = 1 ))
+                character=`echo $cycle | cut -c$iii`
+                character_found=false
+                while [[ "$character" != ""  &&  $character_found = false ]]
+                do
+                   case  $character  in
+                      (0|1|2|3|4|5|6|7|8|9)  true;;
+                      (*)  character_found=true
+                   esac
+                   (( iii = iii + 1 ))
+                   character=`echo $cycle | cut -c$iii`
+                done
+
+                if [[ $character_found = false ]]
+                then
+                   (( icycle = $cycle ))
+                fi
+             fi >|$errfile 2>&1    # AUSGABE FEHLER AUF ERRFILE WENN CYCLE NICHTNUMERISCH
+
+
+                # INFORMATIVE AUSGABE, WENN DATEI NICHTNUMERISCHE EXTENSION HAT
+                # if [[ $(cat $errfile | grep -c "bad number") != 0 ]]
+             if [[ $character_found = true ]]
+             then
+                if [[ $cycle != "$5" ]]
+                then
+                   printf "  +++ file \"$text\" has non-numerical extension \".$cycle\" \n"
+                   locat=file; exit
+                else
+                   if [[ $silent = false ]]
+                   then
+                      printf "  >>> file \"$text\" has non-numerical extension \".$cycle\" \n"
+                   fi
+                fi
+             fi
+
+             if (( icycle > maxcycle ))
+             then
+                (( maxcycle = icycle ))
+             fi
+          fi
+
+       else
+
+             # IM ABSOLUT-MODUS MUSS NUR GEPRUEFT WERDEN, OB DIE DATEI
+             # VORHANDEN IST
+          [[ $4 = $zeile ]]  &&  found=true
+       fi
+
+    done <$filelist
+ fi
+
+ if [[ $found = true ]]
+ then
+    if [[ $get = false ]]
+    then
+       if [[ $absolut = false ]]
+       then
+          if [[ $append = false ]]
+          then
+             (( maxcycle = maxcycle + 1 ))
+             zyklusnr=".$maxcycle"
           else
-             text=${line}
-          fi
-
-             # GET AND REMOVE CYCLE NUMBER, IF EXISTING, AND CHECK, IF FILE EXISTS
-          cycle=${text##*.}
-          if [[ $cycle = $text ]]
-          then
-                # filename contains no dot, i.e. no cycle number
-             if [[ "$text" = "$4" ]]
-             then
-                found=true
-                (( icycle = 0 ))
-             fi
-          else
-                # filename contains at least one dot
-                # find out if the string after the last dot is a number
-             if [[ $cycle =~ ^-?[0-9]+$ ]]
-             then
-                text=${text%.*}
-                if [[ "$text" = "$4" ]]
-                then
-                   found=true
-                   (( icycle = $((10#$cycle)) ))
-                fi
+             if (( maxcycle == 0 ))
+             then
+                zyklusnr=""
              else
-                if [[ "$text" = "$4" ]]
-                then
-                   found=true
-                   (( icycle = 0 ))
-                fi
-             fi
-          fi
-
-          if (( icycle > maxcycle ))
-          then
-             (( maxcycle = icycle ))
-          fi
-
-       else
-
-             # ABSOLUT-MODE ONLY REQUIRES TO CHECK IF FILE EXISTS
-          [[ $4 = $line ]]  &&  found=true
-       fi
-
-    done <$filelist
- fi
-
- if [[ $found = true ]]
- then
-    if [[ $get = false ]]
-    then
-       if [[ $absolut = false ]]
-       then
-          if [[ $append = false ]]
-          then
-             (( maxcycle = maxcycle + 1 ))
-
-                # TRY TO USE FIXED CYCLE NUMBER, IF GIVEN AS OPTION
-             if [[ "$usecycle" != "" ]]
-             then
-                if (( usecycle >= maxcycle ))
-                then
-                   (( maxcycle = usecycle ))
-                else
-                    printf "  >>> Unified cycle number cannot be used\n"
-                fi
-             fi
-          fi
-          cyclestring=`printf ".%03d" $maxcycle`
+                zyklusnr=".$maxcycle"
+             fi
+          fi
        else
           if [[ $overwrite = false ]]
@@ -475,20 +431,20 @@
        if [[ $absolut = false ]]
        then
-             # MAKE CYCLE NUMBER THREE DIGITS WIDE
-          cyclestring=`printf ".%03d" $maxcycle`
-       else
-          cyclestring=""
-       fi
-    fi
-
+          if (( maxcycle == 0 ))
+          then
+             zyklusnr=""
+          else
+             zyklusnr=".$maxcycle"
+             (( maxcycle = 0 ))
+          fi
+       else
+          zyklusnr=""
+       fi
+    fi
  else
-
-    if [[ "$usecycle" != "" ]]
-    then
-       (( maxcycle = usecycle ))
-    fi
-    cyclestring=`printf ".%03d" $maxcycle`
-
-       # EXIT, IF FILE SHALL BE GET FROM THE TARGET HOST, BUT DOESN'T EXIST
+    zyklusnr=""
+
+       # ABBRUCH, WENN DATEI VON ZIELRECHNER GEHOLT WERDEN SOLL, DORT ABER
+       # NICHT VORHANDEN IST
     if [[ $get = true ]]
     then
@@ -500,9 +456,18 @@
 
 
-    # IF NAME-OPTION (-n) IS CHOSEN, ONLY DETERMINE THE LOCAL FILENAME ON THE
-    # TARGET HOST AND EXIT THE SCRIPT
+    # FALLS KATALOG ERZEUGT WIRD, DARF DIE DATEI IN KEINEM FALL EINE
+    # ZYKLUSNUMMER BESITZEN, DA SIE JA NOCh GARNICHT EXISTIEREN KANN
+ if [[ $make_catalog = force ]]
+ then
+    zyklusnr=""
+    (( maxcycle = 0 ))
+ fi
+
+ 
+    # FALLS NAMENSOPTION (-n) GEWAEHLT WURDE, NUR DEN ERMITTELTEN LOKALEN
+    # DATEINAMEN DES ZIELRECHNERS AUSGEBEN UND SCRIPT BEENDEN
  if [[ $print_local_filename = true ]]
  then
-    printf "$4$cyclestring\n"
+    printf "$4$zyklusnr\n"
     rm -r $filelist
     exit
@@ -510,20 +475,19 @@
 
 
-    # IF A 5. ARGUMENT IS GIVEN, IT WILL BE PUT AS FILENAME EXTENSION/APPENDIX
-    # AFTER THE CYCLE NUMBER (ONLY WORKS IN CASE OF FILE COPY TO THE TARGET HOST)
+    # FALLS 5. ARGUMENT ANGEGEBEN WURDE, WIRD DIES ALS FILE-EXTENSION
+    # HINTER DIE ZYKLUS-NUMMER GEHAENGT (FUNKTIONIERT NUR BEI KOPIEREN EINER
+    # DATEI AUF ZIELRECHNER
  if [[ "$5" != ""  &&  $get = false ]]
  then
-    cyclestring=${cyclestring}.$5
- fi
-
-
-    # IN CASE OF FOLDER TRANSER TO THE TARGET HOST, CHECK IF ARGUMENT $3 REALLY
-    # REFERS TO A FOLDER ON THE TARGET HOST
+    zyklusnr=${zyklusnr}.$5
+ fi
+
+
+    # BEI VERZEICHNISTRANSFER VON ZIELRECHNER AUF LOKALEN RECHNER PRUEFEN, OB
+    # $3 AUF ZIELRECHNER WIRKLICH EIN VERZEICHNIS IST
  if [[ $catalog_copy = true  &&  $get = true ]]
  then
-
     rm -rf $filelist
-    ssh $SSH_PORTOPT $1 -l $remote_user "cd $3" > $filelist
-
+    ssh $1 -l $remote_user "cd $3" > $filelist
     if [[ $? != 0 ]]
     then
@@ -536,10 +500,9 @@
        locat=directory; exit
     fi
-
- fi
-
-
-    # IN CASE OF FOLDER TRANSFER FROM THE TARGET HOST TO THE LOCAL HOST,
-    # CREATE THE RESPECTIVE FOLDER ON THE LOCAL HOST
+ fi
+
+
+    # BEI KATALOGTRANSFER AUF LOKALEN RECHNER ENTSPRECHENDES VERZEICHNIS
+    # ANLEGEN
  if [[ $catalog_copy = true ]]
  then
@@ -551,9 +514,16 @@
 
 
+    # Auf IBM-Rechnern (HLRN) Tilde aus Katalognamen entfernen, da scp
+    # diese nicht versteht
  catalog_name=$3
+ if [[ $(hostname | cut -c1-4) = hreg  ||  $(hostname | cut -c1-4) = breg ]]
+ then
+    catalog_name=${catalog_name#"~/"}
+    catalog_name=${catalog_name#"~"}
+ fi
  [[ "$catalog_name" != "" ]]  &&  catalog_name=${catalog_name}/
 
 
-    # COPY FILE/FOLDER VIA SCP
+    # DATEI/VERZEICHNIS PER SCP UEBERTRAGEN
  if [[ $get = false ]]
  then
@@ -562,10 +532,19 @@
        if [[ $append = false ]]
        then
-
-          if [[ $catalog_copy = false ]]
-          then
-             scp $PORTOPT -p $2 $remote_user@$1:$catalog_name$4$cyclestring  > /dev/null
+          if [[ $(echo $local_host | cut -c1-2) = cs ]]
+          then
+             if [[ $catalog_copy = false ]]
+             then
+                scp -q -v $2 $remote_user@$1:$catalog_name$4$zyklusnr
+             else
+                scp -r -q -v $2 $remote_user@$1:$catalog_name$4$zyklusnr
+             fi
           else
-             scp $PORTOPT -p -r $2 $remote_user@$1:$catalog_name$4$cyclestring  > /dev/null
+             if [[ $catalog_copy = false ]]
+             then
+                scp $2 $remote_user@$1:$catalog_name$4$zyklusnr  > /dev/null
+             else
+                scp -r $2 $remote_user@$1:$catalog_name$4$zyklusnr  > /dev/null
+             fi
           fi
           scp_status=$?
@@ -573,9 +552,10 @@
           if [[ $scp_status != 0 ]]
           then
-                # CHECK, IF FILE SIZES ON LOCAL HOST AND TARGET HOST MATCH
+                # CHECK, OB DATEIGROESSEN AUF LOKALEM UND REMOTERECHNER
+                # UEBEREINSTIMMEN
              local_size=`ls -al  $2`
              local_size=`echo $local_size | cut -d" " -f5`
 
-             remote_size=`ssh $SSH_PORTOPT $1 -l $remote_user "ls -al $catalog_name$4$cyclestring"`
+             remote_size=`ssh $1 -l $remote_user "ls -al $catalog_name$4$zyklusnr"`
              remote_size=`echo $remote_size | cut -d" " -f5`
 
@@ -588,16 +568,14 @@
              fi
           fi
-
-       else
-
-          scp $PORTOPT -p $2 $remote_user@$1:${catalog_name}batch_scp_append_file.$random  > /dev/null
-
+       else
+          scp $2 $remote_user@$1:${catalog_name}batch_scp_append_file.$random  > /dev/null
           if [[ $? != 0 ]]
           then
-                # CHECK, IF FILE SIZES ON LOCAL HOST AND TARGET HOST MATCH
+                # CHECK, OB DATEIGROESSEN AUF LOKALEM UND REMOTERECHNER
+                # UEBEREINSTIMMEN
              local_size=`ls -al  $2`
              local_size=`echo $local_size | cut -d" " -f5`
 
-             remote_size=`ssh $SSH_PORTOPT $1 -l $remote_user "ls -al ${catalog_name}batch_scp_append_file.$random"`
+             remote_size=`ssh $1 -l $remote_user "ls -al ${catalog_name}batch_scp_append_file.$random"`
              remote_size=`echo $remote_size | cut -d" " -f5`
 
@@ -613,6 +591,5 @@
           rm  $filelist
 
-          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
-
+          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
           if [[ $? != 0 ]]
           then
@@ -628,16 +605,11 @@
           fi
        fi
-
     else
-
-       ssh $SSH_PORTOPT $1 -l $remote_user "mkdir -p $3"
-
+       ssh $1 -l $remote_user "mkdir -p $3"
        if [[ $? != 0 ]]
        then
           locat=ssh_failed_4; exit
        fi
-
-       scp $PORTOPT -p $2 $remote_user@$1:$catalog_name$4$cyclestring  > /dev/null
-
+       scp $2 $remote_user@$1:$catalog_name$4$zyklusnr  > /dev/null
        if [[ $? != 0 ]]
        then
@@ -658,6 +630,5 @@
        else
 
-          scp $PORTOPT -p $remote_user@$1:$catalog_name$4$cyclestring $2  > /dev/null
-
+          scp $remote_user@$1:$catalog_name$4$zyklusnr $2  > /dev/null
           if [[ $? != 0 ]]
           then
@@ -666,5 +637,4 @@
 
        fi
-
     else
 
@@ -672,11 +642,16 @@
        locat=unavailable_feature; exit
 
-    fi
-
- fi
-
-
-
-    # DELETE TRANSFERED FILE ON THE LOCAL HOST
+#       ftp -i $1 << %END%  > /dev/null
+#$transfermode
+#cd $3
+#mget *
+#quit
+#%END%
+    fi
+ fi
+
+
+
+    # EVTL. TRANSFERIERTE DATEI AUF LOKALEM RECHNER LOESCHEN
  if [[ $delete = true  &&  $get = false ]]
  then
@@ -686,5 +661,5 @@
 
 
-    # FINAL MESSAGES
+    # ABSCHLUSSMELDUNG
  if [[ $silent = false ]]
  then
@@ -703,10 +678,10 @@
           if [[ $catalog_copy = false ]]
           then
-             printf "      new file has cycle number .%03d \n" $maxcycle
+             printf "      new file has cycle number $maxcycle \n"
           else
-             printf "      new catalog has cycle number .%03d \n" $maxcycle
-          fi
-       else
-          printf "      append to cycle number .%03d \n" $maxcycle
+             printf "      new catalog has cycle number $maxcycle \n"
+          fi
+       else
+          printf "      append to cycle number $maxcycle \n"
        fi
     fi
