File: pact-transfer

package info (click to toggle)
pact 980714-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 13,096 kB
  • ctags: 26,034
  • sloc: ansic: 109,076; lisp: 9,645; csh: 7,147; fortran: 1,050; makefile: 136; lex: 95; sh: 32
file content (174 lines) | stat: -rwxr-xr-x 4,464 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/csh
#>
#> PACT-TRANSFER - transfer the PACT distribution from one host to another
#>
#>  
#> Usage: pact-transfer -sh <src-host> -sd <src-directory> -dh <dst-host> -dd <dst-directory>
#>                      [-p] [-sp] [-dp] [-u]
#>  
#> Options: 
#>    -sh  Source host
#>    -sd  Source directory
#>    -su  Source user id (defaults to uid)
#>    -sp  Request source password
#>    -dh  Destination host
#>    -dd  Destination directory
#>    -du  Destination user id (defaults to anonymous
#>    -dp  Request destination password
#>    -p   Request password
#>    -u   Do not delete the the source files
#>  
#
# Modification History:
#   08-16-94 Jan Moura, LLNL:  Expanded prolog
####################
# Source Version: 2.0
# Software Release #92-0043
#
# include "cpyright.h"
#

if ($?USER == 0) then
   if ($?LOGNAME == 0) then
      set USER = "anonymous"
   else
      set USER = $LOGNAME
   endif
endif

set SrcHost = FALSE
set DstHost = FALSE
set SrcDir  = FALSE
set DstDir  = FALSE
set DelDist = TRUE
set help    = FALSE
set LogFile = ~/transfer.log
set SUser   = $USER
set SPasswd = ""
set DUser   = "anonymous"
set DPasswd = "$SUser@$DstHost"
set Pattern = 'pact.README pact*-src pact*.tar.gz'

while ($#argv >= 1)
   switch ($1)
      case -dd:
	       shift
               set DstDir = $1
               breaksw
      case -dh:
	       shift
               set DstHost = $1
               breaksw
      case -du:
	       shift
               set DUser = $1
               breaksw
      case -dp:
               echo -n "Destination Password: "
               stty -echo
               set DPasswd = $<
               stty echo
               echo ""
               breaksw
      case -sd:
	       shift
               set SrcDir = $1
               breaksw
      case -sh:
	       shift
               set SrcHost = $1
               breaksw
      case -su:
	       shift
               set SUser = $1
               breaksw
      case -sp:
               echo -n "Source Password: "
               stty -echo
               set SPasswd = $<
               stty echo
               echo ""
               breaksw
      case -p:
               echo -n "Password: "
               stty -echo
               set Passwd = $<
               stty echo
               echo ""
               set SPasswd = $Passwd
               set DPasswd = $Passwd
	       set Passwd = ""
               breaksw
      case -u:
               set DelDist = FALSE
               breaksw
      default:
               set help = TRUE
               breaksw
   endsw
   shift
end

if (($DstDir == "FALSE") || ($DstHost == "FALSE") || ($SrcDir == "FALSE") || ($SrcHost == "FALSE") || ($help == "TRUE")) then
   echo " "
   echo "Usage: pact-transfer -sh <src-host> -sd <src-directory> -dh <dst-host> -dd <dst-directory>"
   echo "                     [-p] [-sp] [-dp] [-u]"
   echo " "
   echo "Options: "
   echo "   -sh  Source host"
   echo "   -sd  Source directory"
   echo "   -su  Source user id (defaults to uid)"
   echo "   -sp  Request source password"
   echo "   -dh  Destination host"
   echo "   -dd  Destination directory"
   echo "   -du  Destination user id (defaults to anonymous"
   echo "   -dp  Request destination password"
   echo "   -p   Request password"
   echo "   -u   Do not delete the the source files"
   echo " "
   exit(1)
endif

rm -f $LogFile
echo "Transferring PACT distribution" > $LogFile

(echo "open $SrcHost" ; \
 echo "user $SUser $SPasswd\" ; \
 echo "prompt" ; \
 echo "bin" ; \
 echo "cd $SrcDir" ; \
 echo "proxy open $DstHost" ; \
 echo "proxy user $DUser $DPasswd" ; \
 echo "proxy bin" ; \
 echo "proxy cd $DstDir" ; \
 echo "proxy mdele $Pattern" ; \
 echo "proxy mget $Pattern" ; \
 echo "proxy close" ; \
 if ($DelDist == "TRUE") echo "$Cmmd""mdele $Pattern" ; \
 echo "quit" ) | ftp -n

set SPasswd = ""
set DPasswd = ""

# echo the FTP command into the log
echo "" >>& $LogFile
echo "FTP Commands for Transfer" >>& $LogFile
(echo "   open $SrcHost" ; \
 echo "   user $SUser xxxxx\" ; \
 echo "   prompt" ; \
 echo "   bin" ; \
 echo "   cd $SrcDir" ; \
 echo "   proxy open $DstHost" ; \
 echo "   proxy user $DUser xxxxx" ; \
 echo "   proxy bin" ; \
 echo "   proxy cd $DstDir" ; \
 echo "   proxy mdele $Pattern" ; \
 echo "   proxy mget $Pattern" ; \
 echo "   proxy close" ; \
 if ($DelDist == "TRUE") echo "   $Cmmd""mdele $Pattern" ; \
 echo "   quit" ) >>& $LogFile

echo "" >>& $LogFile

exit($status)