#!/bin/bash # #This program is free software; you can redistribute it and/or modify #it under the terms of the GNU General Public License as published by #the Free Software Foundation; either version 2 of the License, or #(at your option) any later version. # #This program is distributed in the hope that it will be useful, #but WITHOUT ANY WARRANTY; without even the implied warranty of #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #GNU General Public License for more details. # #You should have received a copy of the GNU General Public License #along with this program; if not, write to the Free Software #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA now=`date +%s` connect_date=`ls -l --time-style=+%s /var/run/pppoe.conf-adsl.pid.pppd | awk '{ print $6 }'` secs=`calc $now - $connect_date` days=`expr $secs / 86400` secs=`calc $secs % 86400` hours=`expr $secs / 3600` if [ `echo -n $hours | wc -c` -eq "1" ]; then hours="0$hours" fi secs=`calc $secs % 3600` minutes=`expr $secs / 60` if [ `echo -n $minutes | wc -c` -eq "1" ]; then minutes="0$minutes" fi secs=`calc $secs % 60 | awk '{ print $1 }'` #echo -n $secs | wc -c #echo -n $secs if [ `echo -n $secs | wc -c` -eq "1" ]; then secs="0$secs" fi echo "Connect-time: $days days, $hours:$minutes:$secs (dialup at `echo $connect_date | awk '{ printf(\"%s\",strftime(\"%Y-%m-%d %H:%M:%S\",$1)); }'`) "