I'm working on a rather large script atm (it already takes 9 arguments). As such, I need to obtain both a server name and domain from the FQDN. From this, I want to both populate the hostname of the server, as well as the domain line in the /etc/resolv.conf file.
Obviously, this isn't working. I know the regex should be correct.
Here are the regex's I'm working with to obtain the hostname and domain portions:
Can anyone recommend an implementation using either sed or perl? Once I have them output to stdout I can cast them into variables, or even directly into the files. I'd appreciate any help anyone can offer. Thanks!
The script is being used immediately following automated system provisioning, so that returns (none).
Basically the script takes in the following as inputs:
<bond0ip> <bond0snm> <bond0network> <eth1ip> <eth1snm> <eth1network> <FQDN> <DGW> <nameserver>
From this it will perform a ton of different actions. <FQDN> had originally just been hostname, however there is now a vendor requirement that we include a domain line in our resolv.conf file, so I have to make it into a FQDN and extract both from the one item so I can write them into the appropriate config files. Hope that clears stuff up a bit.
The easiest way would be if I could put in host name and domain separately, but as far as I know you can't use more than 9 arguments in a shell script (at least I've always had issues since $10 is viewed as $1 plus a 0).
you probably can't get much help without posting your script or at least relevant portions of it... nobody really wants to guess how you're trying to do everthing.
the way you're doing your hostname and domain seems a lot more complicated then it needs to be.
if, for example, you input your FQDN and assign it to a varialbe called FQDN
Actually in this case $i does not contain an enumeration but the parameter values, so it isn't necessary to use curly brackets, but the quotes are necessary to capture arguments that contain space characters..
As I said, and as you mentioned in your post, if you have bash, then it opens up more possibilities (that are even more efficient). It's just not portable, Bourne shell wise.