herno24
|
2013-01-04
, 00:41
|
Posts: 87 |
Thanked: 14 times |
Joined on Jan 2012
|
#411
|
|
2013-01-04
, 01:14
|
Moderator |
Posts: 6,215 |
Thanked: 6,400 times |
Joined on Nov 2011
|
#412
|
|
2013-01-04
, 01:29
|
Posts: 87 |
Thanked: 14 times |
Joined on Jan 2012
|
#413
|
herno24, i haven't looked at your modification but what i did worked for me, did you install bc and have dc already? If you don't have bc it wont work...
|
2013-01-04
, 02:22
|
Posts: 87 |
Thanked: 14 times |
Joined on Jan 2012
|
#414
|
#!/bin/sh # Warn in red if data left <20% tx=$(gconftool -g /cellui/settings/datacounter/transfer/gprs_home_tx_bytes) rx=$(gconftool -g /cellui/settings/datacounter/transfer/gprs_home_rx_bytes) total=$(($tx+$rx)) consumed=$((total/1000000)) usage=$(gconftool -g /cellui/settings/datacounter/general/gprs_home_notification_period_UI) amount=`dc $total $usage / p` if [ $(echo "$amount > 0.800" |bc) -eq 1 ] then echo "{{red}}$consumed MB" else echo "{{cyan}}$consumed MB" fi exit 1
|
2013-01-04
, 02:58
|
Moderator |
Posts: 6,215 |
Thanked: 6,400 times |
Joined on Nov 2011
|
#415
|
#!/bin/sh # Warn in red if data left <20% # Data usage in cyan if data left not <20% tx=$(gconftool -g /cellui/settings/datacounter/transfer/gprs_home_tx_bytes) rx=$(gconftool -g /cellui/settings/datacounter/transfer/gprs_home_rx_bytes) total=$(($tx+$rx)) usage=$(gconftool -g /cellui/settings/datacounter/general/gprs_home_notification_period_UI) totalMB=$((($tx+$rx)/1000000)) amount=`dc $total $usage / p` if [ $(echo "$amount > 0.800" |bc) -eq 1 ] then echo {{red}}"Data left < 20%" else echo {{cyan}}"Data used = $totalMB MB" fi exit 1
The Following User Says Thank You to thedead1440 For This Useful Post: | ||
|
2013-01-04
, 03:09
|
Posts: 87 |
Thanked: 14 times |
Joined on Jan 2012
|
#416
|
herno24,
My script for what you want:
Code:#!/bin/sh # Warn in red if data left <20% # Data usage in cyan if data left not <20% tx=$(gconftool -g /cellui/settings/datacounter/transfer/gprs_home_tx_bytes) rx=$(gconftool -g /cellui/settings/datacounter/transfer/gprs_home_rx_bytes) total=$(($tx+$rx)) usage=$(gconftool -g /cellui/settings/datacounter/general/gprs_home_notification_period_UI) totalMB=$((($tx+$rx)/1000000)) amount=`dc $total $usage / p` if [ $(echo "$amount > 0.800" |bc) -eq 1 ] then echo {{red}}"Data left < 20%" else echo {{cyan}}"Data used = $totalMB MB" fi exit 1
|
2013-01-04
, 03:10
|
Moderator |
Posts: 6,215 |
Thanked: 6,400 times |
Joined on Nov 2011
|
#417
|
I don't know why, but it doesn't work. I installed bc from your attachment and dc via terminal (apt-get install dc), is that correct?.
|
2013-01-04
, 03:26
|
Posts: 87 |
Thanked: 14 times |
Joined on Jan 2012
|
#418
|
Edit 2: Do a sh /path/to/script as user in terminal to see if the output satisfies what you want before putting it into Billboard...
#!/bin/sh: not found dc: Could not open file 242418745 dc: Could not open file 1000000000 dc: Will not attempt to process directory / dc: Could not open file p (standard_in) 1: syntax error sh: 1: unknown operand {{cyan}}Data used = 242 MB
|
2013-01-04
, 03:31
|
Moderator |
Posts: 6,215 |
Thanked: 6,400 times |
Joined on Nov 2011
|
#419
|
|
2013-01-04
, 03:40
|
Posts: 87 |
Thanked: 14 times |
Joined on Jan 2012
|
#420
|
Can you do a dc of those values manually in terminal not via sh script?
~ $ usage=$(gconftool -g /cellui/settings/datac ounter/general/gprs_home_notification_period_UI) ~ $ totalMB=$((($tx+$rx)/1000000)) -/bin/sh: arithmetic syntax error ~ $ `dc $total $usage / p` dc: Could not open file 1000000000 dc: Will not attempt to process directory / dc: Could not open file p