menuimage

Description

Conffile

Options

Dependencies

License

Changelog

Download

My_Other_Sites

My_Programs

Comments

three-credit-checker v2.9 [21 May 2017] by Dominic

Description

Check and show remaining credit or allowances on phone accounts from Hutchison Three (H3G) mobile network in UK (https://www.three.co.uk/).

For pay-as-you-go (PAYG) phones it can check the remaining credit and in quiet mode will be silent unless the credit is below the warning level that you have set (in pounds). For pay-monthly (aka contract or PAYM) phones it can check the remaining minutes in the allowance, the remaining texts and the remaining data, and show a warning if any of these are below your specified warning level.

Any 'unlimited' or 'all-you-can-eat' allowances are reported as '100000' - for easier post-processing.

Written in bash for use on Linux or (under Windows) Cygwin. Note the dependencies (below), especially that form-extractor.sh must be accessible in the same directory as three-credit-checker.sh.

Conffile

Account information should be in a conf file shown by the -c option. If this is unspecified three-credit-checker.sh will search for conf file three-credit-checker.conf in the same location as three-credit-checker.sh. In the conffile, each phone/account should be on a separate line thus (blank lines and lines beginning with a hash symbol are ignored):

# for a pay-as-you-go (PAYG) account
nickname phonenumber password creditwarnlevel
# for a pay-monthly (PAYM) account (note: 4th parameter 'm' is not used)
nickname phonenumber password m minswarn 3-to-3minswarn textwarn datawarn

Here is a 2-line conf file example:
jimjones 07465987654 myPassword 2.25
janet 07421234567 H4rdNUMbrrr m 50 30 10 100

When three-credit-checker.sh is run using this example conf file it will generate a warning to the 'standard error' device if the credit on the first (PAYG) phone is below £2.25, and for the second phone it will generate a warning if there are, for this month, either 50 minutes or less left for normal calls, or 30 minutes or less left for 3-to-3 calls, or 10 texts or less, or 100MB or less.

If you set any warning level to zero then no warnings will be issued for that parameter.

The 'nickname' can be any text to help you identify the phone, it is for local use only and is not passed to or matched against any data held by Three.

Options

-c - conffile - specify name and location of conffile
-h - show help and exit
-l - show changelog and exit
-n nickname - only run for the given nickname (which must be listed in conffile)
-q - quiet mode - only show warnings or errors
-r - if iframe not found, pause 10m and retry - up to 5 times
-s - skip program title header and output data in csv format
-t - skip program title header (e.g. to pipe to column)
-v - verbose mode - show login progress

Dependencies

form-extractor: https://www.timedicer.co.uk/programs/help/form-extractor.sh.php
awk bash curl coreutils grep lynx sed

License

Copyright © 2017 Dominic Raferd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Changelog

2.9 [21 May 2017]: skip (reporting error) if My3 page says it has 'problem'
2.8 [19 Oct 2016]: small change to match change on My3 website, small corrections to help text
2.7 [02 Jun 2016]: allow to work for different users
2.6 [25 May 2016]: small changes but probably not significant
2.5 [05 May 2016]: report if My3 is officially unavailable
2.4 [04 May 2016]: further adaptations, accommodate 'all-you-can-eat calls'
2.3 [11 Mar 2016]: adaptation for changes to Three website
2.2 [08 Feb 2016]: bugfix for PAYG, sometimes didn't pick up total credit
2.1 [11 Nov 2015]: bugfix - wasn't notifying when credit below warning level
2.0 [25 Jun 2015]: bugfixed and simplified data extraction by using lynx to create text version of web page
1.9 [18 May 2015]: move cookiejar files from /tmp to /var/tmp
1.8 [15 Apr 2015]: v small adaptation for change on Three's iframed-webpage
1.7 [07 Apr 2015]: bugfix
1.6 [27 Jan 2015]: minor bugfix with expiry date of bundle on PAYG
1.5 [04 Nov 2014]: minor bugfix with -s option
1.4 [03 Nov 2014]: add a nickname field, option -n now tests against this
1.3 [28 Oct 2014]: for PAYG, show free internet MB and expiry date
1.2 [27 Oct 2014]: add some permission checking
1.1 [26 Aug 2014]: bugfix to overcome a Three website change
1.0 [17 Jul 2014]: with 'all-you-can-eat data' add-on, report data MB as 100000
0.9 [20 May 2014]: add -r option
0.8 [10 May 2014]: exit with code 10 if one or more warnings were issued
0.7 [25 Apr 2014]: improve help text, skip blank lines in conf file
0.6 [14 Apr 2014]: report if My3 is offline
0.5 [09 Apr 2014]: add -n and -s options, -s output optimized for data analysis, conf file format changed a little
0.4 [03 Apr 2014]: code and help info improvements, add detection of 3-to-3 minutes
0.3 [02 Apr 2014]: help text changes, first public release
0.2 [17 Mar 2014]: for pay-monthly, check remaining text and data
0.1 [13 Mar 2014]: first version

Download three-credit-checker.sh

My Other Sites

My Programs

Here is a selection of some (other) programs I have written, most of which run from the command line (CLI), are freely available and can be obtained by clicking on the links. Dependencies are shown and while in most cases written for a conventional Linux server, they should run even on a Raspberry Pi, and many can run under Windows using Cygwin. Email me if you have problems or questions, or if you think I could help with a programming requirement.

Backup Utilities

Debian/Ubuntu kernel and LVM Utilities

Dellmont / Three / Giffgaff / Vodafone - VoIP and Mobile Phone Account Utilities

Miscellaneous Programs

Comments

No comments yet
*Name:
Email:
Hide my email
*Text:
 
Powered by Scriptsmill Comments Script