Created
January 28, 2020 08:41
-
-
Save dais0n/24901225f917c5f10622043b342a3b59 to your computer and use it in GitHub Desktop.
script...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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