Quantcast
Channel: Micro Focus Forums
Viewing all articles
Browse latest Browse all 11924

Very Basic shell script problem - beginner alert...

$
0
0
I'm developing a SUSE11/OES11 autoyast installation and have run into a glitch. I reckon its an easy shell script fix, but my knowledge of shell scripting is pretty much zero, so please excuse.

The problem I've run into is in populating the hosts file after getting hostname and ip address with ask. I want to get the conventional hosts file entry with
# IP-address Full-Qualified-Hostname Short-hostname

However what I get using autoyast xml like this (using ask to populate)
<host>
<hosts config:type="list">
<hosts_entry>
<host_address>192.168.1.1</host_address>
<names config:type="list">
<name>hostname</name>
<name>hostname.somedomain.com</name>
</names>
</hosts_entry>
</hosts>
</host>

is

# IP-address Full-Qualified-Hostname
# IP-address Short-hostname

and I'm told this is "as designed".

So at the moment I have a line in /etc/hosts of
IP-address Full-Qualified-Hostname
and in /etc/HOSTNAME just the string
Full-Qualified-Hostname

So what I reckon I want to do is to read /etc/HOSTNAME into a variable parse it into say $FQDN and $HOSTONLY and then use sed to edit /etc/hosts with s/$FQDN/$FQDN $HOSTONLY/

I've got as far as working out I probably need to use awk to do the parsing, but the syntax of getting the data from /etc/HOSTNAME and parsing it into the variables is making my brain hurt...

So, how do I do that, or are there any better ideas?

Viewing all articles
Browse latest Browse all 11924

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>