2012-06-08 143 views
0

我寫了一個bash腳本,並且我在每分鐘在Ubuntu 12.04中用cron運行它。ftp mput只發送四個文件 - ubuntu

這裏下面你可以看到我的ftp上傳腳本:

#!/bin/sh 
HOST='192.168.10.40' 
USER='user1' 
PASSWD='Oo123456' 
FILE='CAM_1_*' 
DIR='SecImg' 
UP='..' 
cd /home/user1/Masaüstü/BBTCP/ 
chmod 777 $FILE 
ftp -v -n $HOST <<__END_OF_SESSION 
user $USER $PASSWD 
type binary 
cd $DIR 
mput $FILE 
cd $UP 
bye 
__END_OF_SESSION 

在目錄有格式CAM_1_IP_EPOCH.jpg

命名例如

CAM_1_192.168.10 10頁不同的文件。 30_12345678.jpg

CAM_1_192.168.10.30_12345688.jpg

CAM_1_192.168.10.30_12345698.jpg

...

CAM_1_192.168.10.30_12345878.jpg

但MPUT只發送4個文件。我如何通過ftp發送所有文件?

當我嘗試這裏給的是輸出:

這裏是輸出:

Connected to 192.168.10.40. 
220-FileZilla Server version 0.9.41 beta 
220-written by Tim Kosse ([email protected]) 
220 Please visit http://sourceforge.net/projects/filezilla/ 
331 Password required for ozen.ozkaya 
230 Logged on 
Remote system type is UNIX. 
?Invalid command 
200 Type set to I 
250 CWD successful. "/SecImg" is current directory. 
mput CAM_1_192.168.10.33_1339750625.jpg? 200 Port command successful 
150 Opening data channel for file transfer. 
226 Transfer OK 
14682 bytes sent in 0.00 secs (5206.2 kB/s) 
mput CAM_1_192.168.10.33_1339750628.jpg? 200 Port command successful 
150 Opening data channel for file transfer. 
226 Transfer OK 
14636 bytes sent in 0.00 secs (4809.2 kB/s) 
mput CAM_1_192.168.10.33_1339750631.jpg? 200 Port command successful 
150 Opening data channel for file transfer. 
226 Transfer OK 
14872 bytes sent in 0.00 secs (5260.2 kB/s) 
mput CAM_1_192.168.10.33_1339750635.jpg? 200 Port command successful 
150 Opening data channel for file transfer. 
226 Transfer OK 
14569 bytes sent in 0.00 secs (4850.8 kB/s) 
mput CAM_1_192.168.10.33_1339750638.jpg? mput CAM_1_192.168.10.33_1339750640.jpg? mput CAM_1_192.168.10.33_1339750644.jpg? mput CAM_1_192.168.10.33_1339750647.jpg? mput CAM_1_192.168.10.33_1339750650.jpg? mput CAM_1_192.168.10.33_1339750654.jpg? mput CAM_1_192.168.10.33_1339750658.jpg? mput CAM_1_192.168.10.33_1339750660.jpg? mput CAM_1_192.168.10.33_1339750694.jpg? mput CAM_1_192.168.10.33_1339750696.jpg? mput CAM_1_192.168.10.33_1339750699.jpg? mput CAM_1_192.168.10.33_1339750703.jpg? mput CAM_1_192.168.10.33_1339750706.jpg? mput CAM_1_192.168.10.33_1339750709.jpg? mput CAM_1_192.168.10.33_1339750713.jpg? mput CAM_1_192.168.10.33_1339750716.jpg? mput CAM_1_192.168.10.33_1339750719.jpg? mput CAM_1_192.168.10.33_1339750723.jpg? 221 Goodbye 

只發送前四個並不能發送休息...

問候

回答

0

我懷疑發生了什麼是bash正在將FILE ='CAM_1_ *'擴展爲本地系統上的完整文件列表,然後mput命令行太長以至於無法處理所有文件。

嘗試在設置FILE後添加'echo $ {FILE}行來查看該變量具有的值。

如果發生這種情況,請在設置FILE之前添加'set -f'命令以禁用文件名擴展。

+0

它可以找到文件,但無法發送。 我將輸出添加到問題 – user1336117

+0

遠程系統上是否存在unent文件,可能是文件權限或所有權會阻止它們被ftp覆蓋? 此外,您可能還想嘗試在多個文件傳輸期間在ftp調用中包括'-i'標誌以關閉交互式提示。 此外''無效命令''輸出二進制'輸出看起來很奇怪。也許只是嘗試'二元'。 – pwan