回答編集履歴

2

追記

2021/08/11 12:30

投稿

shiketa
shiketa

スコア4114

test CHANGED
@@ -41,3 +41,131 @@
41
41
  ...
42
42
 
43
43
  ```
44
+
45
+
46
+
47
+ ---
48
+
49
+ ---
50
+
51
+
52
+
53
+ 追記。
54
+
55
+
56
+
57
+ > >別案。files変数からgetとdeleteのコマンドを生成して、まとめてftpに食わせる。
58
+
59
+ > 何度も申し訳ありません。
60
+
61
+ > こちらの案ですが、どのようにfile変数からコマンドを生成するのでしょうか?
62
+
63
+ > 試しに
64
+
65
+ > getCommnd=("get test.jpg" "get test2.jpg")
66
+
67
+ > として、ftpのヒアドキュメントのget使用箇所に
68
+
69
+ > ${getCommnd[@]}
70
+
71
+ > として置換えてみましたが、コマンドと認識されませんでした。
72
+
73
+
74
+
75
+
76
+
77
+ ftp環境なんて身近に建っていないので、ローカルなファイルを例に。
78
+
79
+
80
+
81
+ ```shell
82
+
83
+ $ ls hoge
84
+
85
+ a b c d e f
86
+
87
+ ```
88
+
89
+
90
+
91
+ ```shell
92
+
93
+ $ cat xx.sh
94
+
95
+ #!/bin/sh
96
+
97
+
98
+
99
+ files=$(cd hoge; ls)
100
+
101
+
102
+
103
+ (
104
+
105
+ echo user id password
106
+
107
+
108
+
109
+ for f in ${files}
110
+
111
+ do
112
+
113
+ cat <<EOD
114
+
115
+ get hoge/${f} local/${f}
116
+
117
+ del hoge/${f}
118
+
119
+ EOD
120
+
121
+ done
122
+
123
+
124
+
125
+ echo bye
126
+
127
+ ) | cat
128
+
129
+ ```
130
+
131
+
132
+
133
+ ```shell
134
+
135
+ $ sh xx.sh
136
+
137
+ user id password
138
+
139
+ get hoge/a local/a
140
+
141
+ del hoge/a
142
+
143
+ get hoge/b local/b
144
+
145
+ del hoge/b
146
+
147
+ get hoge/c local/c
148
+
149
+ del hoge/c
150
+
151
+ get hoge/d local/d
152
+
153
+ del hoge/d
154
+
155
+ get hoge/e local/e
156
+
157
+ del hoge/e
158
+
159
+ get hoge/f local/f
160
+
161
+ del hoge/f
162
+
163
+ bye
164
+
165
+ ```
166
+
167
+
168
+
169
+ xx.shの最後のcatをftp -nとかに変える。
170
+
171
+ なお、ftpのサブコマンド自体、さっぱり思い出せないので内容はとても適当です。

1

typo

2021/08/11 12:30

投稿

shiketa
shiketa

スコア4114

test CHANGED
@@ -11,6 +11,10 @@
11
11
 
12
12
 
13
13
  files=$(ftp <<EOD
14
+
15
+ ...
16
+
17
+ dir
14
18
 
15
19
  ...
16
20