-
-
-
-
-
-
-
-
|
Copyright © 2004-2019, Schackmann
webmaster(at)schackmann.net
|
|
sitegen.sh
Diese Site wurde damit erzeugt.
#!/bin/bash
#
# Website generator script
# Stefan Schackmann, 9/2003
#
# var defs
SRCDIR=$PWD/
TGTDIR=$PWD/site/
SUBDIR=
FILE=
HEADER=header
NAVBAR=navbar
FOOTER=footer
echo $SRCDIR $TGTDIR
# test params
# funcs
error() {
echo $ERR
exit 1
}
fcn_filegen() {
echo filegen $FILE
INFILE=$SRCDIR$SUBDIR$FILE
OUTFILE=`echo $TGTDIR$SUBDIR$FILE | sed 's/cont_//g'`.html
SFL=`echo $FILE | sed 's/cont_//'`.html
TMP=
if [ ! -r $INFILE ]; then
ERR="XXX Input file missing"
error
fi
if [ ! -x $TGTDIR$SUBDIR ]; then
mkdir $TGTDIR$SUBDIR
fi
touch $OUTFILE
case "$SUBDIR" in
'')
fcn_topdir;;
en/)
fcn_endir;;
de/)
fcn_dedir;;
fr/)
fcn_frdir;;
esac
}
fcn_topdir() {
cat $HEADER |\
sed -e 's/=\"..\//=\"/g' \
-e "s|THISFILE|$SFL|" >> $OUTFILE
cat $NAVBAR |\
sed -e 's/href=\"/href=\"de\//g' \
-e 's/de\/index/index/' >> $OUTFILE
cat $INFILE >> $OUTFILE
cat $FOOTER >> $OUTFILE
}
fcn_endir() {
cat $HEADER |\
sed -e "s|THISFILE|$SFL|" >> $OUTFILE
cat en/$NAVBAR >> $OUTFILE
cat $INFILE |\
sed -e 's/index/..\/index/' >> $OUTFILE
cat $FOOTER >> $OUTFILE
}
fcn_dedir() {
cat $HEADER |\
sed -e "s|THISFILE|$SFL|" >> $OUTFILE
cat de/$NAVBAR >> $OUTFILE
cat $INFILE >> $OUTFILE
cat $FOOTER >> $OUTFILE
}
fcn_frdir() {
cat $HEADER |\
sed -e "s|THISFILE|$SFL|" >> $OUTFILE
cat fr/$NAVBAR |\
sed -e 's/index/..\/index/' >> $OUTFILE
cat $INFILE >> $OUTFILE
cat $FOOTER >> $OUTFILE
}
# cleanup first
if [ -x $TGTDIR ]; then
echo erasing $TGTDIR
rm -rf $TGTDIR
fi
mkdir $TGTDIR
cp -f $SRCDIR/main.css $TGTDIR/main.css
cp -fr $SRCDIR/img $TGTDIR/
# here we go
FILE=cont_index
fcn_filegen
SUBDIR=en/
for FILE in `ls $SUBDIR | grep cont_ | grep -v "~"`; do
fcn_filegen
done
SUBDIR=de/
for FILE in `ls $SUBDIR | grep cont_ | grep -v "~"`; do
fcn_filegen
done
SUBDIR=fr/
for FILE in `ls $SUBDIR | grep cont_ | grep -v "~"`; do
fcn_filegen
done
exit 0
- getlog.sh
Holt logfiles vom Provider per ftp und legt sie in Tagesdirectories ab, cron_daily getriggert.
#!/bin/sh
#
# gets actual logs via ftp from provider
# Schackmann, Aug 2001
#
echo 'starting getlog'
test -e ~/logs || mkdir ~/logs
cd ~/logs/
echo `pwd`
echo 'creating timestamp-directory'
CURDA="log"`date +"%Y%m%d"`
echo $CURDA
mkdir $CURDA
cd $CURDA
echo `pwd`
echo 'building ftp download script'
echo 'open 127.0.0.1' > getlog.ftp
echo 'user' >> getlog.ftp
echo 'password' >> getlog.ftp
echo 'cd path/to/logs' >> getlog.ftp
echo 'get A.log' >> getlog.ftp
echo 'get B.log' >> getlog.ftp
echo 'get C.log' >> getlog.ftp
echo 'close' >> getlog.ftp
echo 'bye' >> getlog.ftp
echo 'starting ftp download'
ftp -s:getlog.ftp
rm -f getlog.ftp
echo 'done.'
exit 0
units
Einheitenumrechung
#!/bin/sh
#
# compute from inunit to outunit
# stefan schackmann
#
USAGE="usage: unit <inunit> <outunit> number
where <inunit> and <outunit> is one of
mm, cm, m, km, in, ft, mi"
IU="" # input unit
OU="" # output unit
((X=1)) # number in <inunit>
((Y=0)) # number in milimeters
((Z=0)) # number in <outunit>
if [ "$1" = "" -o "$2" = "" ];
then
echo $USAGE
exit 1
else
IU=$1
OU=$2
fi
if [ "$3" != "" ]; then
((X=$3))
fi
case $IU in
mm)
((Y=$X));;
cm)
((Y=$X*10));;
m)
((Y=$X*1000));;
km)
((Y=$X*1000000));;
in)
((Y=$X*254/10));;
ft)
((Y=$X*2844/10));;
mi)
((Y=$X*1610000));;
*)
echo unkown unit $1
echo $USAGE
exit 1;;
esac
case $OU in
mm)
echo $Y;;
cm)
echo $(($Y/10))\.$(($Y%10));;
m)
echo $(($Y/1000))\.$(($Y%1000));;
km)
echo $(($Y/1000000))\.$(($Y%1000000));;
in)
echo $(($Y*10/254))\.$(($Y*10%254));;
ft)
echo $(($Y*10/2844))\.$(($Y*10%2844));;
mi)
echo $(($Y/1610000))\.$(($Y/1610000));;
*)
echo unknown unit $OU
echo $USAGE
exit 1;;
esac
exit 0
|
|