source: palm/trunk/SCRIPTS/batch_scp @ 2715

Last change on this file since 2715 was 2715, checked in by raasch, 7 years ago

last commit documented

  • Property svn:keywords set to Id
File size: 22.2 KB
Line 
1#! /bin/bash
2
3# batch_scp - script for automatic file/directory transfer using scp
4
5#--------------------------------------------------------------------------------#
6# This file is part of the PALM model system.
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-2017  Leibniz Universitaet Hannover
20#--------------------------------------------------------------------------------#
21#
22# Current revisions:
23# ------------------
24#
25#
26# Former revisions:
27# -----------------
28# $Id: batch_scp 2715 2017-12-27 11:31:43Z raasch $
29# bugfix: variable cycle explicitly interpreted with 10 as the number base
30#
31# 2714 2017-12-27 11:25:57Z raasch
32# cycle numbers made three digits wide
33# host depending code completely removed
34#
35# 2261 2017-06-08 14:25:57Z raasch
36# option usecycle added, script is running under bash now,
37# filenames are allowed to contain arbitrary number of dots "."
38#
39# 1310 2014-03-14 08:01:56Z raasch
40#
41# 1202 2013-07-10 16:22:07Z witha
42# adjustments for Forwind cluster (lcflow): using absolute paths for ssh
43#
44# 1099 2013-02-10 01:47:43Z raasch
45# LANG variable is unset in some ssh calls to guarantee messages in English
46#
47# 1094 2013-02-03 01:52:12Z raasch
48# new option -P for explicit setting of ssh/scp port
49#
50# 1090 2013-02-02 07:06:13Z raasch
51# code put under GPL (PALM 3.9)
52# adjustments for Kyushu-University computing center (lckyut)
53# old changelog messages removed
54#
55# 08/03/11 - Siggi - adjustments for ibmkisti: this machine allows
56#                    outgoing ssh/scp connections only from the
57#                    interactive nodes (gaiad). All ssh/scp traffic is
58#                    done via this interactive node.
59# 04/01/02 - Siggi - first version finished
60# 29/11/01 - Siggi - script development started
61#
62#--------------------------------------------------------------------------------#
63# batch_scp - script for automatic file/directory transfers using scp
64#
65# batch_scp has up to 5 arguments (first 4 are mandatory):
66#               $1 = IP-addres of remote (target) machine
67#               $2 = file to be transferred
68#               $3 = directory of remote machine, where file should be copied to
69#               $4 = filename that file should be given on remote machine
70#               $5 = file extension (optional argument)
71#
72# ATTENTION: problems might occur if directories on remote machine include very
73#            old files for which "ls -al" does give "year" as modification
74#            time instead of "hh:mm". In such a case, batch_scp cannot check the
75#            filename and may not find the file (e.g. if option -g is used).
76#--------------------------------------------------------------------------------#
77
78
79 
80    # VARIABLENVEREINBARUNGEN + DEFAULTWERTE
81 random=$RANDOM
82
83 absolut=false
84 append=false
85 catalog_copy=false
86 check=false
87 cyclestring=""
88 delete=false
89 errfile=batch_scp.errfile.$random
90 filelist=filelist.$random
91 get=false
92 local_host=`hostname`
93 local_wdir=`pwd`
94 locat=normal
95 make_catalog=false
96 overwrite=false
97 print_local_filename=false
98 quote_wait=false
99 remote_user=""
100 silent=false
101 transfermode=binary
102 typeset -i iii icycle maxcycle=0 usecycle wait=0
103
104    # FEHLERBEHANDLUNG
105    # BEI EXIT:
106 trap 'if [[ $locat != normal ]]
107       then
108          [[ -f "$filelist" ]]  &&  cat $filelist
109          [[ -f "$errfile"  ]]  &&  cat $errfile
110          rm -rf $filelist $errfile
111          printf " +++ BATCH_SCP terminated \n"
112          printf "     locat     = $locat \n"
113          printf "     arguments = $1 $2 $3 $4 \n\n"
114          exit 1
115       fi' exit
116
117
118    # BEI TERMINAL-BREAK:
119 trap 'rm -rf $filelist $errfile
120       printf " +++ BATCH_SCP terminated \n\n"
121       exit 1
122      ' 2
123
124
125    # SHELLSCRIPT-OPTIONEN EINLESEN
126 while  getopts  :aAbcCdgmnoP:qsu:U:w:  option
127 do
128   case  $option  in
129       (a)   absolut=true;;
130       (A)   append=true;;
131       (b)   transfermode=binary;;
132       (c)   catalog_copy=true;;
133       (C)   check=true;;
134       (d)   delete=true;;
135       (g)   get=true;;
136       (m)   make_catalog=true;;
137       (n)   print_local_filename=true;;  # Option ist nicht dokumentiert !
138       (o)   overwrite=true;;
139       (P)   scp_port=$OPTARG;;
140       (q)   quote_wait=true;;
141       (s)   silent=true;;
142       (u)   remote_user=$OPTARG;;
143       (U)   usecycle=$OPTARG;;
144       (w)   wait=$OPTARG;;
145       (\?)  printf "  +++ option $OPTARG unknown \n"
146             printf "  --> call: batch_scp [-aAbcCdgmnoqsuw] <IP-adress> <localfile> <remotepath> <remotefile>\n"
147             locat=parameter;exit;;
148   esac
149 done
150
151 (( to_shift = $OPTIND - 1 ))
152 shift $to_shift
153
154
155
156 
157    # KURZE AUFRUFBESCHREIBUNG WIRD HIER AUSGEGEBEN
158 if [ "$1" = "?" ]
159 then
160   (printf "\n  *** batch_scp can be called as follows:\n"
161    printf "\n      batch_scp -a -b -d -g -o -q -s -u.. -U.. -w..  <param1> <param2> <param3> <param4>\n"
162    printf "\n      Description of available options:\n"
163    printf "\n      Option  Description                            Default-Value"
164    printf "\n        -a    Filenames are absolute. No cycle-      ---"
165    printf "\n              numbers will be determined"
166    printf "\n        -A    append to destination file             ---"
167    printf "\n        -b    use binary-modus for transfer          ASCII-modus"
168    printf "\n        -c    transfer of directory                  ---"
169    printf "\n        -C    check-Modus, no transfer               ---"
170    printf "\n        -d    file to be transferred will be         ---"
171    printf "\n              deleted after successful transfer"
172    printf "\n        -g    change of transfer direction, i.e.     ---"
173    printf "\n              file will be transferred from"
174    printf "\n              destination host"
175    printf "\n        -o    any existing file will be overwritten  ---"
176    printf "\n        -q    switch on  \"quote wait\"  on          ---"
177    printf "\n              estination host"
178    printf "\n        -s    do not display informative messages    ---"
179    printf "\n        -u    username on remote machine             <username>"
180    printf "\n        -U    cycle number to be used                ---"
181    printf "\n        -w    waiting time in seconds, before trans- 0"
182    printf "\n              fer will be initiated"
183    printf "\n "
184    printf "\n      The positional parameters <param1> - <param4> must be provided at"
185    printf "\n      any time and have the following meaning:"
186    printf "\n        <param1>  -  IP-adress of destination host"
187    printf "\n                     or \"?\"  (creates this outline)"
188    printf "\n        <param2>  -  abs. or rel. path of file to be transferred"
189    printf "\n        <param3>  -  directory (abs.!) on destination host. Special cahracters"
190    printf "\n                     like \~ are allowed but must be quoted by \"."
191    printf "\n        <param4>  -  filename (without path!) on destination host; must not"
192    printf "\n                     be given, if option -c is used."
193    printf "\n      When using option -g, file will be copied from destination host to file"
194    printf "\n      <param2>. In this case, no overwriting is possible.") | more
195    exit
196 fi
197
198
199    # PRUEFEN, OB ALLE ARGUMENTE VORLIEGEN
200 if [[ "$1" = "" ]]
201 then
202    printf " +++ 1. argument missing \n"
203    locat=argument; exit
204 elif [[ "$2" = "" ]]
205 then
206    printf " +++ 2. argument missing \n"
207    locat=argument; exit
208 elif [[ "$3" = "" ]]
209 then
210    printf " +++ 3. argument missing \n"
211    locat=argument; exit
212 elif [[ "$4" = "" ]]
213 then
214    printf " +++ 4. argument missing \n"
215    locat=argument; exit
216 fi
217
218
219    # USER-NAME AUF ZIELRECHNER AUS .NETRC-DATEI ERMITTELN
220 if [[ -z $remote_user ]]
221 then
222
223       # PRUEFEN, OB NETRC-DATEI VORHANDEN
224    if [[ ! -f ~/.netrc ]]
225    then
226       printf " +++ option -u not given; \n"
227       printf "     getting remote-username from password file failed \n"
228       printf "     because ~/.netrc does not exist \n"
229       locat=netrc; exit
230    fi
231    grep  $1  ~/.netrc | read dum dum dum remote_user dum dum
232 fi
233
234
235    # APPEND IST NUR BEI TRANSFER EINZELNER DATEIEN OHNE UEBERSCHREIBEN
236    # ERLAUBT. GET IST DABEI EBENFALLS NICHT ERLAUBT
237 if [[ $append = true  &&  ( $get = true || $catalog_copy = true || $overwrite = true ) ]]
238 then
239    printf " +++ options -g, -c and -o are not allowed, if -A is given \n"
240    locat=parameter; exit
241 fi
242
243
244    # QUOTE WAIT FUNKTIONIERT NICHT BEIM KOPIEREN GANZER VERZEICHNISSE
245 if [[ $quote_wait = true  &&  $catalog_copy = true ]]
246 then
247    printf " +++ options  -c  and  -q  must not be used simultaneously\n"
248    locat=parameter; exit
249 fi
250
251
252    # IM CHECK-MODUS WIRD SCRIPT HIER BEENDET
253 [[ $check = true ]]  &&  exit
254
255
256    # BESTIMMTE ZEIT WARTEN, BIS WEITERGEMACHT WIRD (NOETIG Z.B. BEI TRANSFER
257    # VON JOBPROTOKOLLEN AUS JOBS HERAUS)
258 sleep  $wait
259
260
261    # Set port number option for calls of ssh/scp, subjob and batch_scp scripts
262 if [[ "$scp_port" != "" ]]
263 then
264    PORTOPT="-P $scp_port"
265    SSH_PORTOPT="-p $scp_port"
266 fi
267
268
269    # PRUEFEN, OB LOKALE DATEI/LOKALES VERZEICHNIS VORHANDEN BZW. NICHT VORHANDEN
270 if [[ $get = false ]]
271 then
272    if [[ $catalog_copy = false ]]
273    then
274       if [[ ! -f $2 ]]
275       then
276          printf " +++ file \"$2\" to be transferred does not exist \n"
277          locat=localfile; exit
278       fi
279    else
280       if [[ ! -d $2 ]]
281       then
282          printf " +++ directory \"$2\" to be transferred does not exist\n"
283          printf "     or is not a directory \n"
284          locat=localfile; exit
285       fi
286    fi
287 else
288    if [[ $catalog_copy = false ]]
289    then
290       if [[ -f $2 ]]
291       then
292          if [[ $overwrite = true ]]
293          then
294             rm  $2
295          else
296             printf " +++ local file \"$2\" is already existing \n"
297             locat=localfile; exit
298          fi
299       else
300
301             # PRUEFEN, OB SICH LOKALE DATEI ANLEGEN LAESST
302          local_dirname=`dirname $2`
303          if [[ ! -d $local_dirname ]]
304          then
305             printf " +++ local directory \"$local_dirname\" \n"
306             printf "     does not exist or is not a directory \n"
307             printf " +++ cannot copy file \"$3/$4\" \n"
308             printf "     from \"$1\" to \"$local_host\" \n"
309             locat=localfile; exit
310          fi
311       fi
312    else
313       if [[ -d $2  ||  -f $2 ]]
314       then
315          printf " +++ local directory \"$2\" is already existing, \n"
316          printf "     or a file with the same name exists \n"
317          locat=localfile; exit
318       fi
319    fi
320 fi
321
322
323    # VERZEICHNISLSTE DES ZIELRECHNERS ERSTELLEN
324 ssh $SSH_PORTOPT $1 -l $remote_user "unset LANG; cd $3; ls -1; echo '*** list complete'" > $filelist  2>&1
325 ssh_status=$?
326
327 if [[ $ssh_status != 0 ]]
328 then
329    if [[ ! -f $filelist ]]
330    then
331       echo " local_host = $local_host   ssh_status = $ssh_status"
332       locat=ssh_failed_1; exit
333    else
334       if [[ $(grep -c "*** list complete" $filelist) = 0 ]]
335       then
336          echo " local_host = $local_host   ssh_status = $ssh_status"
337          locat=ssh_failed_2; exit
338       fi
339    fi
340 fi
341
342
343    # PRUEFEN, OB VERZEICHNIS VORHANDEN IST. WENN GANZES VERZEICHNISS ZUM
344    # ZIELRECHNER KOPIERT WERDEN SOLL, DARF DORT NOCH KEIN ENTSPRECHENDES
345    # VERZEICHNIS VORHANDEN SEIN
346 if [[ $(cat $filelist | grep -c "not found") != 0  || \
347       $(cat $filelist | grep -c "No such file or directory") != 0 ]]
348 then
349    if [[ ! ( $catalog_copy = true  &&  $get = false ) ]]
350    then
351       if [[ $make_catalog = false ]]
352       then
353          printf " +++ directory \"$3\" does not exist on destination host (\"$1\") \n"
354          locat=directory; exit
355       else
356          if [[ $silent = false ]]
357          then
358             printf "  >>> directory \"$3\" does not exist on destination host (\"$1\")"
359             printf "\n      trying to create \"$3\" \n"
360          fi
361
362          make_catalog=force
363       fi
364    fi
365 fi
366
367
368    # PRUEFEN, OB DATEI/VERZEICHNIS VORHANDEN, WENN JA, HOECHSTEN ZYKLUS
369    # ERMITTELN (BZW. IM ABSOLUT-MODUS PRUEFEN, OB DATEI VORHANDEN IST)
370    # DAS GANZE ABER NUR, WENN NICHT OVERWRITE-MODUS GEWAEHLT WURDE, DIE
371    # EVENTUELL VORHANDENE DATEI ALSO UEBERSCHRIEBEN WERDEN SOLL
372 found=false
373 if [[ ( $overwrite = false   &&  $get = false )  ||  $get = true ]]
374 then
375    while  read zeile
376    do
377       if [[ $absolut = false ]]
378       then
379             # REMOVE EXTENSION, IF EXISTING AND GIVEN AS ARGUMENT
380          if [[ "$5" != ""  &&  "$5" != " " ]]
381          then
382             extension=${zeile##*.}
383             if [[ $extension = $5 ]]
384             then
385                text=${zeile%.*}
386             else
387                text=${zeile}
388             fi
389          else
390             text=${zeile}
391          fi
392
393             # GET AND REMOVE CYCLE NUMBER, IF EXISTING, AND CHECK, IF FILE EXISTS
394          cycle=${text##*.}
395          if [[ $cycle = $text ]]
396          then
397                # filename contains no dot, i.e. no cycle number
398             if [[ "$text" = "$4" ]]
399             then
400                found=true
401                (( icycle = 0 ))
402             fi
403          else
404                # filename contains at least one dot
405                # find out if the string after the last dot is a number
406             if [[ $cycle =~ ^-?[0-9]+$ ]]
407             then
408                text=${text%.*}
409                if [[ "$text" = "$4" ]]
410                then
411                   found=true
412                   (( icycle = $((10#$cycle)) ))
413                fi
414             else
415                if [[ "$text" = "$4" ]]
416                then
417                   found=true
418                   (( icycle = 0 ))
419                fi
420             fi
421          fi
422
423          if (( icycle > maxcycle ))
424          then
425             (( maxcycle = icycle ))
426
427                 # FOR COMPATIBILITY REASONS WITH OLDER VERSIONS
428                 # CHECK IF CYCLE NUMBER CONTAINS LEADING ZEROS
429              if [[ $(echo $cycle | cut -c1) = 0 ]]
430              then
431                 leading_zero=true
432              else
433                 leading_zero=false
434              fi
435          fi
436
437       else
438
439             # IM ABSOLUT-MODUS MUSS NUR GEPRUEFT WERDEN, OB DIE DATEI
440             # VORHANDEN IST
441          [[ $4 = $zeile ]]  &&  found=true
442       fi
443
444    done <$filelist
445 fi
446
447 if [[ $found = true ]]
448 then
449    if [[ $get = false ]]
450    then
451       if [[ $absolut = false ]]
452       then
453          if [[ $append = false ]]
454          then
455             (( maxcycle = maxcycle + 1 ))
456
457                # TRY TO USE FIXED CYCLE NUMBER, IF GIVEN AS OPTION
458             if [[ "$usecycle" != "" ]]
459             then
460                if (( usecycle >= maxcycle ))
461                then
462                   (( maxcycle = usecycle ))
463                else
464                    printf "  >>> Unfied cycle number cannot be used\n"
465                fi
466             fi
467             cyclestring=`printf ".%03d" $maxcycle`
468          else
469             if (( maxcycle == 0 ))
470             then
471                cyclestring=""
472             else
473                cyclestring=`printf ".%03d" $maxcycle`
474             fi
475          fi
476       else
477          if [[ $overwrite = false ]]
478          then
479             printf "  +++ file \"$3/$4\" \n"
480             printf "      already exists on destination host (use -o, if necessary) \n"
481             locat=file; exit
482          fi
483       fi
484    else
485       if [[ $absolut = false ]]
486       then
487          if (( maxcycle == 0 ))
488          then
489             cyclestring=""
490          else
491
492                # MAKE CYCLE NUMBER THREE DIGITS WIDE
493             if [[ $leading_zero = true ]]
494             then
495                cyclestring=`printf ".%03d" $maxcycle`
496             else
497                cyclestring=.$maxcycle
498             fi
499             (( maxcycle = 0 ))
500          fi
501       else
502          cyclestring=""
503       fi
504    fi
505
506 else
507
508    if [[ "$usecycle" != "" ]]
509    then
510       (( maxcycle = usecycle ))
511       cyclestring=`printf ".%03d" $usecycle`
512    else
513       cyclestring=""
514    fi
515
516       # ABBRUCH, WENN DATEI VON ZIELRECHNER GEHOLT WERDEN SOLL, DORT ABER
517       # NICHT VORHANDEN IST
518    if [[ $get = true ]]
519    then
520       printf " +++ file \"$3/$4\" \n"
521       printf "     does not exist on destination host (\"$1\") \n"
522       locat=remotefile; exit
523    fi
524 fi
525
526
527    # FALLS KATALOG ERZEUGT WIRD, DARF DIE DATEI IN KEINEM FALL EINE
528    # ZYKLUSNUMMER BESITZEN, DA SIE JA NOCh GARNICHT EXISTIEREN KANN
529 if [[ $make_catalog = force ]]
530 then
531    cyclestring=""
532    (( maxcycle = 0 ))
533 fi
534
535 
536    # FALLS NAMENSOPTION (-n) GEWAEHLT WURDE, NUR DEN ERMITTELTEN LOKALEN
537    # DATEINAMEN DES ZIELRECHNERS AUSGEBEN UND SCRIPT BEENDEN
538 if [[ $print_local_filename = true ]]
539 then
540    printf "$4$cyclestring\n"
541    rm -r $filelist
542    exit
543 fi
544
545
546    # FALLS 5. ARGUMENT ANGEGEBEN WURDE, WIRD DIES ALS FILE-EXTENSION
547    # HINTER DIE ZYKLUS-NUMMER GEHAENGT (FUNKTIONIERT NUR BEI KOPIEREN EINER
548    # DATEI AUF ZIELRECHNER
549 if [[ "$5" != ""  &&  $get = false ]]
550 then
551    cyclestring=${cyclestring}.$5
552 fi
553
554
555    # BEI VERZEICHNISTRANSFER VON ZIELRECHNER AUF LOKALEN RECHNER PRUEFEN, OB
556    # $3 AUF ZIELRECHNER WIRKLICH EIN VERZEICHNIS IST
557 if [[ $catalog_copy = true  &&  $get = true ]]
558 then
559
560    rm -rf $filelist
561    ssh $SSH_PORTOPT $1 -l $remote_user "cd $3" > $filelist
562
563    if [[ $? != 0 ]]
564    then
565       locat=ssh_failed_3; exit
566    fi
567
568    if [[ $(cat $filelist | grep -c "Not a directory") != 0 ]]
569    then
570       printf " +++ \"$3\" on destination host is not a directory \n"
571       locat=directory; exit
572    fi
573
574 fi
575
576
577    # BEI KATALOGTRANSFER AUF LOKALEN RECHNER ENTSPRECHENDES VERZEICHNIS
578    # ANLEGEN
579 if [[ $catalog_copy = true ]]
580 then
581    if [[ $get = true ]]
582    then
583       mkdir $2
584    fi
585 fi
586
587
588 catalog_name=$3
589 [[ "$catalog_name" != "" ]]  &&  catalog_name=${catalog_name}/
590
591
592    # DATEI/VERZEICHNIS PER SCP UEBERTRAGEN
593 if [[ $get = false ]]
594 then
595    if [[ $make_catalog != force ]]
596    then
597       if [[ $append = false ]]
598       then
599
600          if [[ $catalog_copy = false ]]
601          then
602             scp $PORTOPT -p $2 $remote_user@$1:$catalog_name$4$cyclestring  > /dev/null
603          else
604             scp $PORTOPT -p -r $2 $remote_user@$1:$catalog_name$4$cyclestring  > /dev/null
605          fi
606          scp_status=$?
607
608          if [[ $scp_status != 0 ]]
609          then
610                # CHECK, OB DATEIGROESSEN AUF LOKALEM UND REMOTERECHNER
611                # UEBEREINSTIMMEN
612             local_size=`ls -al  $2`
613             local_size=`echo $local_size | cut -d" " -f5`
614
615             remote_size=`ssh $SSH_PORTOPT $1 -l $remote_user "ls -al $catalog_name$4$cyclestring"`
616             remote_size=`echo $remote_size | cut -d" " -f5`
617
618             if [[ "$remote_size" != "$local_size" ]]
619             then
620                echo " +++ scp failed on host \"$local_host\" with exit $scp_status"
621                echo "     local size = \"$local_size\"  remote size = \"$remote_size\" "
622                date
623                locat=scp_failed; exit
624             fi
625          fi
626
627       else
628
629          scp $PORTOPT -p $2 $remote_user@$1:${catalog_name}batch_scp_append_file.$random  > /dev/null
630
631          if [[ $? != 0 ]]
632          then
633                # CHECK, OB DATEIGROESSEN AUF LOKALEM UND REMOTERECHNER
634                # UEBEREINSTIMMEN
635             local_size=`ls -al  $2`
636             local_size=`echo $local_size | cut -d" " -f5`
637
638             remote_size=`ssh $SSH_PORTOPT $1 -l $remote_user "ls -al ${catalog_name}batch_scp_append_file.$random"`
639             remote_size=`echo $remote_size | cut -d" " -f5`
640
641             if [[ "$remote_size" != "$local_size" ]]
642             then
643                echo " +++ scp failed on host \"$local_host\" with exit $scp_status"
644                echo "     local size = \"$local_size\"  remote size = \"$remote_size\" "
645                date
646                locat=scp_for_append_failed; exit
647             fi
648          fi
649
650          rm  $filelist
651
652          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
653
654          if [[ $? != 0 ]]
655          then
656             if [[ ! -f $filelist ]]
657             then
658                locat=append_via_ssh_failed; exit
659             else
660                if [[ $(grep -c "*** append complete" $filelist) = 0 ]]
661                then
662                   locat=append_via_ssh_failed; exit
663                fi
664             fi
665          fi
666       fi
667
668    else
669
670       ssh $SSH_PORTOPT $1 -l $remote_user "mkdir -p $3"
671
672       if [[ $? != 0 ]]
673       then
674          locat=ssh_failed_4; exit
675       fi
676
677       scp $PORTOPT -p $2 $remote_user@$1:$catalog_name$4$cyclestring  > /dev/null
678
679       if [[ $? != 0 ]]
680       then
681          locat=scp_failed; exit
682       fi
683    fi
684
685 else
686
687    if [[ $catalog_copy = false ]]
688    then
689       if [[ $quote_wait = true ]]
690       then
691
692          printf " +++ quote wait not realized with BATCH_SCP"
693          locat=unavailable_feature; exit
694
695       else
696
697          scp $PORTOPT -p $remote_user@$1:$catalog_name$4$cyclestring $2  > /dev/null
698
699          if [[ $? != 0 ]]
700          then
701             locat=scp_failed; exit
702          fi
703
704       fi
705
706    else
707
708       printf " +++ get of whole cataloges not realized with BATCH_SCP so far"
709       locat=unavailable_feature; exit
710
711    fi
712
713 fi
714
715
716
717    # EVTL. TRANSFERIERTE DATEI AUF LOKALEM RECHNER LOESCHEN
718 if [[ $delete = true  &&  $get = false ]]
719 then
720    rm -rf  $2
721 fi
722
723
724
725    # ABSCHLUSSMELDUNG
726 if [[ $silent = false ]]
727 then
728    if (( maxcycle == 0 ))
729    then
730       if [[ $append = false ]]
731       then
732          printf "  >>> transfer successful \n"
733       else
734          printf "  >>> file was appended \n"
735       fi
736    else
737       printf "  >>> transfer successful \n"
738       if [[ $append = false ]]
739       then
740          if [[ $catalog_copy = false ]]
741          then
742             printf "      new file has cycle number .%03d \n" $maxcycle
743          else
744             printf "      new catalog has cycle number .%03d \n" $maxcycle
745          fi
746       else
747          printf "      append to cycle number .%03d \n" $maxcycle
748       fi
749    fi
750 fi
751
752 rm -rf  $filelist  $errfile
Note: See TracBrowser for help on using the repository browser.