Skip to content

Instantly share code, notes, and snippets.

@Zibri
Last active April 19, 2020 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zibri/d5454403ad28393739f31817d929cd96 to your computer and use it in GitHub Desktop.
Save Zibri/d5454403ad28393739f31817d929cd96 to your computer and use it in GitHub Desktop.
BASH script to know remaining credit in megabytes from etisalat data simcard
#!/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
@Zibri
Copy link
Author

Zibri commented Jun 10, 2019

#requirements
sudo apt install curl jq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment