Code:
#!/bin/bash
for LOGFILE in `ls -t /var/log/messages*`; do
LASTHNGUP=`grep "PAP authentication succeeded" $LOGFILE | tail -1`
if [ $? == 0 ]; then
DATE=`echo $LASTHNGUP | tr -s " " | cut -d" " -f1-3`
if [ "$DATE" ]; then
echo "Last redial: $DATE"
exit;
fi
fi
done
if [ "!$DATE" ]; then
for LOGFILE in `ls -t /var/log/messages*.gz`; do
LASTHNGUP=`zgrep "PAP authentication succeeded" $LOGFILE | tail -1`
if [ $? == 0 ]; then
DATE=`echo $LASTHNGUP | tr -s " " | cut -d" " -f1-3`
if [ "$DATE" ]; then
echo "Last redial: $DATE"
exit;
fi
fi
done
fi
DL=`ifconfig ppp0|grep bytes|cut -d"(" -f2|cut -d" " -f1`
let DOWNLOADED="$DL/1024/1024"
if [ "$DOWNLOADED" ]; then
echo "Downloaded for this stanza: $DOWNLOADED MB"
fi
my problem is that I run the lastdial checks and when it gets a result, it exits. how can I make it continue with the remaining code?
and if anyone knows a better way I can run the first 2 scripts as one, please let me know.