Skip to content

Instantly share code, notes, and snippets.

@dais0n
Created January 28, 2020 08:41
Show Gist options
  • Save dais0n/24901225f917c5f10622043b342a3b59 to your computer and use it in GitHub Desktop.
Save dais0n/24901225f917c5f10622043b342a3b59 to your computer and use it in GitHub Desktop.
script...
#!/bin/sh
# ==========
# help
# ==========
function _help() {
cat << EOS
this script download file from servers written in server list file
-h help
-s server list file
-p download log path
-o output dir
ex:
./download_log.sh -s server_list.txt -p /var/log/dais0n/access.log -o /tmp
EOS
}
# ==========
# argument
# ==========
while getopts n:c:h:f:p:o: OPT
do
case $OPT in
h) _help
exit 0
;;
f) server_list_file=$OPTARG
;;
o) output_path=$OPTARG
;;
p) download_path=$OPTARG
;;
\?) _help
exit 0
;;
esac
done
# ==========
# main
# ==========
while read server
do
[ -d ${output_path}/${server} ] || mkdir -p ${output_path}/${server}
scp -oStrictHostKeyChecking=no ${server}:${download_path} ${output_path}/${server}
done < ${server_list_file}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment