Active Topics

 


Reply
Thread Tools
Posts: 2,290 | Thanked: 4,133 times | Joined on Apr 2010 @ UK
#1
I am having a issue with a script I am trying to write and I just can't work out why it's not working.

The issue is that on my N900 the multiply command on line 47 doesn't multiply correctly.
It however seems to work fine on my Ubuntu desktop which is puzzling me.
I have tried multiple methods to calculate but it just isn't correct.
I am trying to multiply a value by 100 (to get percent) and you can clearly tell that it isn't doing so.

The script is to calculate swap de-fragmentation without needing iostat

Any help will be greatly appreciated. Thanks
Attached Files
File Type: gz swapblocks.sh.tar.gz (906 Bytes, 64 views)
__________________

Wiki Admin
sixwheeledbeast's wiki
Testing Squad Subscriber
- mcallerx - tenminutecore - FlopSwap - Qnotted - zzztop - Bander - Fight2048 -


Before posting or starting a thread please try this.

Last edited by sixwheeledbeast; 2012-12-04 at 21:39.
 
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#2
quickly trying this in N9 at least it works...

~ #
~ # oneh=100 ; getcurrent=123 ; timeshundred=$(($getcurrent*$oneh)) ; echo $timeshundred
12300
~ #

So it seems that N900 has different shell... What does it give as an answer there?
 

The Following 2 Users Say Thank You to juiceme For This Useful Post:
Moderator | Posts: 6,215 | Thanked: 6,400 times | Joined on Nov 2011
#3
Originally Posted by juiceme View Post
quickly trying this in N9 at least it works...

~ #
~ # oneh=100 ; getcurrent=123 ; timeshundred=$(($getcurrent*$oneh)) ; echo $timeshundred
12300
~ #

So it seems that N900 has different shell... What does it give as an answer there?
works on the n900 too:
Code:
/home/user # oneh=100 ; getcurrent=123 ;timeshundred=$(($get
current*$oneh)) ; echo $timeshundred
12300
/home/user #
 

The Following User Says Thank You to thedead1440 For This Useful Post:
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#4
Okaay, then there is no other possibility than for some reason $getcurrent does not evaluate to a number.
 
Posts: 1,163 | Thanked: 1,873 times | Joined on Feb 2011 @ The Netherlands
#5
Did you try the same script in bash? There are some minor differences between ash and bash

Try to run the script from bash, need to have bash3 (packagename) installed though.
__________________
N900 loaded with:
CSSU-T (Thumb)
720p recording,
Pierogi, Lanterne, Cooktimer, Frogatto
N9 16GB loaded with:
Kernel-Plus
--
[TCPdump & libpcap | ngrep]
--
donate
 

The Following User Says Thank You to mr_pingu For This Useful Post:
Posts: 50 | Thanked: 120 times | Joined on Apr 2010 @ Poland
#6
No idea why it wouldn't work. Maybe try replacing timeshundred formula with $(expr $oneh \* $getcurrent) ?
__________________
.:different kinds of pop
 
Posts: 2,290 | Thanked: 4,133 times | Joined on Apr 2010 @ UK
#7
Originally Posted by thedead1440 View Post
works on the n900 too:
Code:
/home/user # oneh=100 ; getcurrent=123 ;timeshundred=$(($get
current*$oneh)) ; echo $timeshundred
12300
/home/user #
Okay so a completely fresh script on the N900 in question with the above works.
So is there something I have done further back in the script that is effecting it?

I have tried "let" and "expr" style claculations with the same results.
I also originally tried just putting "$getcurrent*100" and got the issue.

Installing bash now to see if it makes a difference.
__________________

Wiki Admin
sixwheeledbeast's wiki
Testing Squad Subscriber
- mcallerx - tenminutecore - FlopSwap - Qnotted - zzztop - Bander - Fight2048 -


Before posting or starting a thread please try this.
 
Posts: 2,290 | Thanked: 4,133 times | Joined on Apr 2010 @ UK
#8
Originally Posted by mr_pingu View Post
Did you try the same script in bash? There are some minor differences between ash and bash

Try to run the script from bash, need to have bash3 (packagename) installed though.
Bash3 installed.
Changed to #!/bin/bash
Works a treat, thank you.
Is this a bug in ash/busybox?
Is there another way of doing this so my application doesn't depend on bash3?
__________________

Wiki Admin
sixwheeledbeast's wiki
Testing Squad Subscriber
- mcallerx - tenminutecore - FlopSwap - Qnotted - zzztop - Bander - Fight2048 -


Before posting or starting a thread please try this.
 
Posts: 1,163 | Thanked: 1,873 times | Joined on Feb 2011 @ The Netherlands
#9
Not a bug of busybox, more of a feature which most of us don't like. Remember busybox is written in mind to be used on embedded devices so basically it's a stripped down version of bash.

It would probably possible to rewrite without the dependence on bash but then you should knock on somebody else door. I am not a good coder/scripter.
__________________
N900 loaded with:
CSSU-T (Thumb)
720p recording,
Pierogi, Lanterne, Cooktimer, Frogatto
N9 16GB loaded with:
Kernel-Plus
--
[TCPdump & libpcap | ngrep]
--
donate
 

The Following User Says Thank You to mr_pingu For This Useful Post:
Posts: 2,290 | Thanked: 4,133 times | Joined on Apr 2010 @ UK
#10
Originally Posted by mr_pingu View Post
Remember busybox is written in mind to be used on embedded devices so basically it's a stripped down version of bash.
Seems odd to make it calculate a simple multiplication incorrectly. I can understand stripping commands to make a lightweight version. Making commands not work correctly is plain stupid IMO.
__________________

Wiki Admin
sixwheeledbeast's wiki
Testing Squad Subscriber
- mcallerx - tenminutecore - FlopSwap - Qnotted - zzztop - Bander - Fight2048 -


Before posting or starting a thread please try this.
 

The Following User Says Thank You to sixwheeledbeast For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 16:35.