Re: Trying to replace a bashism in bourne sh
- In reply to: D'Arcy Cain : "Re: Trying to replace a bashism in bourne sh"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 07 Nov 2023 15:49:26 UTC
On 07/11/2023 13:53, D'Arcy Cain wrote:
> On 2023-11-07 02:21, Arthur Chance wrote:
>> On 06/11/2023 18:45, D'Arcy Cain wrote:
>>> I need to do this;
>>>
>>> ifconfig_eth3="inet $((16#c0a8c0${me} + 100))/24"
>>>
>>> Problem is that I need to do this at boot time but then it runs as
>>> bourne sh. Does anyone have an equivalent for sh?
>>
>> I'm not totally familiar with bash but that (16#c0a8c0) is a hexadecimal
>> number equivalent to an address triplet 192.168.192. I'd guess ${me} is
>
> I should have explained more. Basically I have a bunch of servers all
> on the same network. I have two ethernet (or more) interfaces on each.
> I am setting up both IPV4 and IPV6 on both the public and the private
> side. I have a script that gets sourced into a small rc.conf for each
> server. The idea was to use the same last octet on every interface.
>
> In the server rc.conf I have something like this:
>
> hostname="smaug.vex.net"
> me=44 # 68
> . /blah/rc.conf # common code
>
> I use hex for "me" so that I can create IPV6 addresses. So far so good.
>
> Recently, someone else set up iLO on some of the servers. To access iLO
> she used one of the extra ports on the servers with more than two and
> put a separate network on it. For some reason she says that she can't
> use the same last octet for that address as the other interfaces. I
> don't know enough about iLO yet to understand why so I am just adding
> the 100 as she did. At least I don't have to worry about IPV6 right now.
>
I see des@ has pointed out that you can use the 0x prefix instead of 16#
in sh (which means I've learnt something new today). That looks like the
easiest option for you.
--
We build our computer systems the way we build our cities; over time,
without a plan, on top of ruins.
— Ellen Ullman