Wednesday, February 14, 2007

BASH Script To Download File

#!/bin/bash
#
# filename: download.sh
# desciption: script to download log files from other server
# how to run: shell>./download.sh

BASE_DIR="/localserver/muntenari/log"
BASE_URL="http://www.muntenari.com/target-logs"

USER="username"
PASS="password"

# verbose, for debuging only
WGET="/usr/bin/wget --http-user=${USER} --http-passwd=${PASS} -c"


LOG_DATE=`cat ${BASE_DIR}/latihan/webalizer/lastdate`
LOG_DIRS=${BASE_DIR}/`echo "${LOG_DATE}" | awk '{print substr($_,0,6)}'`

ACCESS_LOG="${BASE_URL}/access_log.${LOG_DATE}.bz2"

# check logs dir. if not exist, create now
if [ ! -d ${LOG_DIRS} ]; then
mkdir -p ${LOG_DIRS}
fi

cd ${LOG_DIRS}

# start download
${WGET} ${ACCESS_LOG}

1 comment:

160012 said...

huy,,,join IndoCoder.Or.ID yuk!
Kita" lg butuh staf neh :D

Regis di forum dan PM gw yak...!