Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- curl --ftp-ssl -k ftp://user:pass@IP
- $ curl -s ftp://user:pass@IP/path/to/folder/ |
- grep -e '^-' | awk '{ print $9 }' |
- while read f; do
- curl -O ftp://user:pass@IP/path/to/folder/$f;
- done
- #!/bin/bash
- #
- # Use cURL to download the files in a given FTPS directory (FTP over SSL)
- # eg:
- # curl_get_ftp_dir -u myUserName -p myPassword -d ftps://ftpserver.com/dir1/dir2
- # Optionally, use:
- # -k - to ignore bad SSL certificates
- # --config userPassFile - to use the contents of a file including myUserName:myPassword in place of command line arguments
- # --silent - to silently download (otherwise cURL will display stats per file)
- while [[ $# -gt 1 ]]
- do
- key="$1"
- case $key in
- -u|--username)
- user="$2"
- shift
- ;;
- -p|--password)
- pass="$2"
- shift
- ;;
- -d|--dir|--directory)
- ftpDir="$2"
- shift
- ;;
- -k|--ignoreSSL|--ignoreBadSSLCertificate)
- ignoreBadSSLCertificate="-k"
- ;;
- -s|--silent)
- silent="-s"
- ;;
- -K|--config|--configFile)
- config="$2"
- shift
- ;;
- *)
- echo "Unknown Option!"
- ;;
- esac
- shift
- done
- if [ -z "${config+x}" ]; then
- CURL_OPTS="$silent --ftp-ssl $ignoreBadSSLCertificate -u $user:$pass"
- else
- #CURL_OPTS="$silent --ftp-ssl $ignoreBadSSLCertificate --config $config"
- #Originally intended to be a curl config file - for simplicity, now just a file with username:password in it
- #Be sure to chmod this file to either 700, 400, or 500
- CURL_OPTS="$silent --ftp-ssl $ignoreBadSSLCertificate -u $(cat $config)"
- fi
- curl $CURL_OPTS $ftpDir |
- grep -e '^-' | awk '{ print $9 }' |
- while read f; do
- curl -O $CURL_OPTS $ftpDir/$f;
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement