-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathftpgetfolder.sh
executable file
·62 lines (49 loc) · 1.07 KB
/
ftpgetfolder.sh
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
if [ "$#" -eq 0 ]; then
echo "ftpgetfolder <config file>"
echo "with config file has:"
echo " - SERVER=<server address>"
echo " - USER=<user name>"
echo " - PASSWD=<user password>"
echo " - LOCAL_DIR=<path to copy ftp folder/files>"
echo " - DISTANT_DIR=<ftp folder to copy from>"
exit
fi
if [ ! -f $1 ]
then
echo ERROR: Config file "$1" does not exist
exit
fi
source $1
if [ -z "$USER" ]
then
ERR=USER is empty
fi
if [ -z "$PASSWD" ]
then
ERR=PASSWD is empty
fi
if [ -z "$SERVER" ]
then
ERR=SERVER is empty
fi
if [ -z "$LOCAL_DIR" ]
then
ERR=LOCAL_DIR is empty
fi
if [ -z "$DISTANT_DIR" ]
then
ERR=DISTANT_DIR is empty
fi
if [ ! -z "$ERR" ]
then
echo ERROR: $ERR
exit
fi
DATE_SUFFIX=`LC_TIME=C.UTF-8 date '+%d%b%y_%Hh%M.%s'`
LOG=$LOCAL_DIR/getfolder$DATE_SUFFIX.log
PYTHON_FILE=~/Documents/scripts/python/ftpmirror.py
echo Log File: $LOG
python $PYTHON_FILE -s $SERVER -l $LOCAL_DIR -r $DISTANT_DIR -u $USER -p $PASSWD ${@: 2} > $LOG
echo >> $LOG
echo ------------------- empty directories: ------------------- >> $LOG
cat $LOG | grep WARN >> $LOG