Last active
April 19, 2020 11:49
-
-
Save Zibri/d5454403ad28393739f31817d929cd96 to your computer and use it in GitHub Desktop.
BASH script to know remaining credit in megabytes from etisalat data simcard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function eticheck () | |
{ | |
param=`curl --proxy "" -sI "http://www.etisalat.eg/etisalat/notification/dashboard.html"|grep param|cut -d " " -f 2|tr -d "\r"` | |
eurl="http://www.etisalat.eg/dashboard/user/profile?dial=param:$param" | |
msisdn=`curl --proxy "" -qs -H 'DNT: 1' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.9,it;q=0.8' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36' -H 'Accept: application/json, text/plain, */*' -H 'Referer: http://www.etisalat.eg/etisalat/notification/dashboard.html' "http://www.etisalat.eg/dashboard/user/msisdn?dial=param:$param" --compressed|jq -r .msisdn` | |
data=`curl --proxy "" -qs -H 'DNT: 1' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.9,it;q=0.8' -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36' -H 'Accept: application/json, text/plain, */*' -H 'Referer: http://www.etisalat.eg/etisalat/notification/dashboard.html' $eurl --compressed` | |
egp=`echo $data |jq -r .balance.englishValue` | |
mb=`echo $data |jq -r .rateplan[0].consumptionDetailsList[0].remaining.value` | |
tot=`echo $data |jq -r .rateplan[0].consumptionDetailsList[0].total.value` | |
rd=`echo $data |jq -r .rateplan[0].renewalDate.englishValue` | |
rds=`date -d $(echo "$rd" | awk -v FS=/ -v OFS=- '{print $3,$2,$1}') +%s` | |
rdd=`date +%s -d '+6 month'` | |
dd=$((rdd-rds)) | |
echo MSISDN: $msisdn | |
echo Balance EGP: $egp | |
echo Remaining MB: $mb | |
echo Renewal date: $rd | |
echo Consumed: $(echo "scale=2;($tot-$mb)/($dd/60/60/24)" | bc -l ) Mb/day. | |
} | |
eticheck |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#requirements
sudo apt install curl jq