Simple command line tool to check your prepaid phone plan balance. (Not a beauty regarding SW design, but working 😉)
This tool can for example be run in a cron job to regularly check your balance and send out an e-mail notification if the balance falls below a given limit.
ℹ️ this tool has exclusively been implemented and tested for https://www.aldi-mobile.ch/ and will require adoption for other providers, but may act as an inspiration :)
- Download the latest release from the releases:
- Create a
.properties
file for your phone number and provider. Use example.properties as a reference - You can run the tool from the console with the following short java command:
java -cp bin:lib/activation-1.1.1.jar:lib/javax.mail-1.6.2.jar balancechecker.impl.ALDISuisseBalanceChecker yourname.properties
- Create a script if you want to use execute the program more frequently.
ℹ️ If you want you can output the log to a file, by appending>> yourname.log
to the script.
e.g.checkbalance.sh
#!/bin/sh
java -cp bin:lib/activation-1.1.1.jar:lib/javax.mail-1.6.2.jar balancechecker.impl.ALDISuisseBalanceChecker yourname.properties >> yourname.log
- Create a cron job to run the script weekly or so
e.g. run every Sunday at 3 AM
0 3 * * 0 cd /path/to/your/copy/of/the/tool && checkbalance.sh
If you want to use this program for other providers, proceed as follows:
- Fork this repo
- Copy balancecheker.impl.ALDISuisseBalanceChecker for your provider
- Change the following functions for your needs:
validateProperties0()
>>> check whether all the settings you need are set in the propertiesgetBalance()
>>> perform the requests to- login to your phone account
- retrieve the balance information
- parse the balance to java.math.BigDecimal
- logout of your account
main(String[] args)
>>> change the third line to use your class- remove unnecessary constants from the top of the class
- Create a pull request for this repo if you want this implementation to be shared:
Working on your first Pull Request? You can learn how from this free series How to make a pull request - Create a console script and schedule a cron job if needed (see How to use? above)