Linux shell script to obtain usage with Telkom ISP

seanl

Member
Joined
Sep 3, 2003
Messages
10
Reaction score
0
Location
.
Improved version (I saw the old one got deleted anyway, but in case someone else does find it useful - I certainly do - I'll post it again).

Replace NNNNN and password with what's appropriate for your account. It usefully prints out a calendar and the date as well for the temporally challenged like me...

#!/bin/sh
USER="[email protected]"
PASS="password"
URL="http://adsl.telkomsa.net/cgi-bin/onlineGraph.cgi?userName=$USER&password=$PASS"
curl -s $URL | sed -ne 's/.*<i>\W*\(Total usage for.*\)\W*<\/i>.*/\1/p'
echo
cal
date
echo
 
Really liked your script [:D]
But I needed something that would log the info to a file for later reference. Here's what I came up with. It outputs the info to your screen and then saves to the LOG location you specify to a file named June-2004.dsl.log or whichever month it is at the time.[;)]
Hope you find it useful [:)]

Code:
#!/bin/sh

USER="[email protected]"
PASS="password"
URL="http://adsl.telkomsa.net/cgi-bin/onlineGraph.cgi?userName=$USER&password=$PASS"
LOG="/root/dslreports"

echo | tee -a $LOG/`date +%B`-`date +%G`.dsl.log
echo "ADSL Usage Report for `date +%A`, `date +%d` `date +%B` `date +%G` at `date +%T`" | tee -a $LOG/`date +%B`-`date +%G`.dsl.log
echo | tee -a $LOG/`date +%B`-`date +%G`.dsl.log
curl -s $URL | sed -ne 's/.*<i>\W*\(Total usage for.*\)\W*<\/i>.*/\1/p' | tee -a $LOG/`date +%B`-`date +%G`.dsl.log
echo  | tee -a $LOG/`date +%B`-`date +%G`.dsl.log
echo ============================================= >> $LOG/`date +%B`-`date +%G`.dsl.log

exit
 
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by lost</i>
Code:
#!/bin/sh

USER="[email protected]"
PASS="password"
URL="http://adsl.telkomsa.net/cgi-bin/onlineGraph.cgi?userName=$USER&password=$PASS"
LOG="/root/dslreports"

echo | tee -a $LOG/`date +%B`-`date +%G`.dsl.log
echo "ADSL Usage Report for `date +%A`, `date +%d` `date +%B` `date +%G` at `date +%T`" | tee -a $LOG/`date +%B`-`date +%G`.dsl.log
echo | tee -a $LOG/`date +%B`-`date +%G`.dsl.log
curl -s $URL | sed -ne 's/.*&lt;i&gt;\W*\(Total usage for.*\)\W*&lt;\/i&gt;.*/\1/p' | tee -a $LOG/`date +%B`-`date +%G`.dsl.log
echo  | tee -a $LOG/`date +%B`-`date +%G`.dsl.log
echo ============================================= &gt;&gt; $LOG/`date +%B`-`date +%G`.dsl.log

exit
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">
<br />This is really useful. I was wondering if there's a way to have
it give you a breakup of how much was uploading and how much is
downloading?[/br]

--
koffiejunkie
 
Improved version (I saw the old one got deleted anyway, but in case someone else does find it useful - I certainly do - I'll post it again).

Replace NNNNN and password with what's appropriate for your account. It usefully prints out a calendar and the date as well for the temporally challenged like me...

#!/bin/sh
USER="[email protected]"
PASS="password"
URL="http://adsl.telkomsa.net/cgi-bin/onlineGraph.cgi?userName=$USER&password=$PASS"
curl -s $URL | sed -ne 's/.*&lt;i&gt;\W*\(Total usage for.*\)\W*&lt;\/i&gt;.*/\1/p'
echo
cal
date
echo
Does this still work?
 
Top
Sign up to the MyBroadband newsletter
X