-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathftp.bash
executable file
·48 lines (46 loc) · 1.26 KB
/
ftp.bash
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
#!/bin/bash
# ftp files from one directory to another.
# Assumes credentials are stored in a file in the home directory named .ftppass
# The password and username can be set in the environment (export FTP_PASS='pass')
# Alternately, the password can be stored is a file in the user's root dir, named .ftp_pass.
#
# Example usage:
# ./ftp.bash --dir /path/to/where/you/want/the/files --host ftp.domain.com
#
# NOTE: FTP IS AN INSECURE PROTOCOL AND SHOULD BE AVOIDED.
SOURCE_DIR='output'
DIR=''
HOST=''
if [ -z "$FTP_USER" ]; then FTP_USER=''; fi
if [ -z "$FTP_PASS" ]; then FTP_PASS=`cat ~/.ftp_pass`; fi
FILES='*'
while [ "$1" != "" ]; do
case $1 in
-s | --source_dir ) shift
SOURCE_DIR=$1
;;
-d | --dir ) shift
DIR=$1
;;
-h | --host ) shift
HOST=$1
;;
-u | --user ) shift
FTP_USER=$1
;;
-f | --files ) shift
FILES=$1
;;
esac
shift
done
cd $SOURCE_DIR
ftp -v -n $HOST << EOF
user $FTP_USER $FTP_PASS
cd $DIR
bin
passive
prompt
mput $FILES
bye
EOF