-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathftp.sh
81 lines (68 loc) · 1.44 KB
/
ftp.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash -
#===============================================================================
#
# FILE: ftp.sh
#
# USAGE: ./ftp.sh
#
# DESCRIPTION:
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: ---
# AUTHOR:
# ORGANIZATION: WSU
# CREATED: 02/15/2017 04:53
# REVISION: ---
#===============================================================================
#set -o nounset # Treat unset variables as an error
user=$1
pass=$2
host="137.190.19.99" #address
file=$(find ./ -name "MOCK_DATA_FILTER_*.zip") #fle to send DONT know the zip ext
ftp_success_msg="226 Transfer Complete"
ftplog=$PWD/tmp/ftplogfile
echo "checking for user and pass"
if [[ -z $user ]] && [[ -z $pass ]]
then
echo "user and pass not provided, sending as annonymous"
#use default annonymous
userd='anonymous'
ftp -nv $host <<EOF > $ftplog
quote user $userd
quote pass $pass
cd MockData
put $file
bye
EOF
grep "230 Login successful" $ftplog
grep "226 Transfer complete" $ftplog
rc=$?
if [[ $rc -eq 0 ]]
then
echo "ftp OK"
else
echo "ftp Error"
exit 1
fi
else
echo "Logging into ftp server as $user"
ftp -nv $host <<EOF > $ftplog
quote user $user
quote pass $pass
put $file
bye
EOF
grep "230 Login successful" $ftplog
grep "226 Transfer complete" $ftplog
rc=$?
if [[ $rc -eq 0 ]]
then
echo "ftp OK"
else
echo "ftp Error"
exit 1
fi
fi
exit 0