Consider it suitable Gawped Atmstombs wrote:Exclusive OR doesn't seem to work...
BUT I have reduced your Bitwise OR to do the original function I wanted in a couple of unintelligible lines for shoto to gawp at!
Code: Select all
l="${IP%.*}";r="${IP#*.}";n="${NM%.*}";m="${NM#*.}" subnet=$((${IP%%.*}&${NM%%.*})).$((${r%%.*}&${m%%.*})).$((${l##*.}&${n##*.})).$((${IP##*.}&${NM##*.}))
Bash script to calculate subnet address from IP and netmask
- Shotokan101
- RouterTech Team
- Posts: 4779
- Joined: Thu Jan 26, 2006 3:17 pm
- Location: Glasgow, Scotland
Jim
.....I'm Sorry But I Can't Do That Dave.....
.....I'm Sorry But I Can't Do That Dave.....
- biro
- RouterTech Team
- Posts: 1274
- Joined: Wed Jan 25, 2006 10:03 pm
- Location: Letchworth Garden City, ENGLAND
- Contact:
XOR doesn't appear to be implemented on the routermstombs wrote:Exclusive OR doesn't seem to work...
Not that it matters much as I got the logic / maths wrong. Appears more complicated than I thought, should still be possible to do it but not by simple logic.
mstombs wrote:BUT I have reduced your Bitwise OR to do the original function I wanted in a couple of unintelligible lines for shoto to gawp at!
I did it the long way as easier to understand without #comments everywhere ! Still had Shoto 'Bashing' his head though
hehe shoto's comments make it all worth while - and the code is now in my version of the half bridge script! I don't need the second challenge - don't waste any time! NOT OR gets closer, but I can't see a way to do it except by iteration - testing that the subnet of each is same against a one of 32 candidates!
- thechief
- RouterTech Team
- Posts: 12067
- Joined: Wed Feb 01, 2006 10:22 pm
- Location: England, the Centre of Africa
- Contact:
Perhaps something that needs to be switched on in the "ash" shell? I don't see anything in the build configuration file that could do this. Perhaps you might want to try the "bash" shell in the repository to see whether it would work there?biro wrote:XOR doesn't appear to be implemented on the routermstombs wrote:Exclusive OR doesn't seem to work...
The Chief: Be sure to read the Firmware FAQ and do a Forum Search before posting!
No support via PM. Ask all questions on the open forum.
No support via PM. Ask all questions on the open forum.
- Shotokan101
- RouterTech Team
- Posts: 4779
- Joined: Thu Jan 26, 2006 3:17 pm
- Location: Glasgow, Scotland