Skip to content

Instantly share code, notes, and snippets.

@freejoe76
Last active March 2, 2016 18:22
Show Gist options
  • Save freejoe76/22d23fda1634929c7980 to your computer and use it in GitHub Desktop.
Save freejoe76/22d23fda1634929c7980 to your computer and use it in GitHub Desktop.
ftp.bash
#!/bin/bash
# ftp files from one directory to another.
# Assumes credentials are stored in a file in the home directory named .ftppass
# NOTE: FTP IS AN INSECURE PROTOCOL AND SHOULD BE AVOIDED.
SOURCEDIR=''
DIR=''
HOST=''
USER=''
PASS=`cat ~/.ftppass`
FILES='*'
while [ "$1" != "" ]; do
case $1 in
-d | --dir ) shift
DIR=$1
;;
-h | --host ) shift
HOST=$1
;;
-u | --user ) shift
USER=$1
;;
-f | --files ) shift
FILES=$1
;;
esac
shift
done
cd $SOURCEDIR
ftp -v -n $HOST << EOF
user $USER $PASS
cd $DIR
bin
passive
prompt
mput $FILES
bye
EOF
#for FILE in `ls *.html`; do echo "mput $FILE"; done
@zloadmin
Copy link

zloadmin commented Mar 2, 2016

Interactive mode off.
local: 1 remote: 1
1: not a plain file.
local: 3 remote: 3
3: not a plain file.
local: 4 remote: 4
4: not a plain file.
local: 5 remote: 5
5: not a plain file.

FOLDER
total 32
8 drwx------+ 182 dedxak newcustomers 4096 марта 2 20:00 1
8 drwx------+ 77 dedxak newcustomers 4096 марта 2 17:10 3
8 drwx------+ 11 dedxak newcustomers 4096 марта 2 07:20 4
8 drwx------+ 15 dedxak newcustomers 4096 марта 2 19:24 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment