Quote:
Originally Posted by
sandholm
Bash has built-in conversion tools. Consider the following:
svn1:~# (( x = 0377 )); echo $x
255
This will assign x the octal value of 0377 (the leading 0 indicates an octal value), which returns the decimal value 255.
svn1:~# (( x = 0xFFFE )); echo $x
65534
This will assign x the hex value of 0xFFFE (the leading 0x means hex), which is the decimal value of 65534.
The use of "((" and "))" is shorthand for the "let" statement.
Thanks my dear friend,
for your excellent solution.
Exactly, it works fine under bash.
My cellular modem generates time ticks every 2 s
in the following format
00001F9C
converting the above hex value into decimal value of
8092
I get a number of seconds my modem Internet connection is on.
Converting seconds into minutes, hours, days for totals,
is exactly what lets me control my airtime.
I have compiled Unix dialog utility for mipsel (router)
to let me open GUI window with session time counters via putty ssh.
Yesterday I tried to test some example shell scripts running dialog widgets
to get no flickered data refresh functionality (ncurses library).
I exprimented with running `date` as " some string" 1st parameter .
Succeeded right now and can run dialog window with data update and no flickering.
`date` is updated in gauge widget box.
wait is 1
So I get data refreshed every second.
Now I will try to preset session time and get session left time displayed
in % + gauge bar.
Jack