<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: /etc/hosts script required: quick one! in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts-script-required-quick-one/m-p/2744845#M944337</link>
    <description>Hi Bill,&lt;BR /&gt;&lt;BR /&gt;I do not know if you can rule out my thoughts because of your environment, but:&lt;BR /&gt;&lt;BR /&gt;1) a dot in a grep expression stands for a single character wildcard ! See this :&lt;BR /&gt;&lt;BR /&gt;# echo 1.1.1.1 &amp;gt; greptarget&lt;BR /&gt;# echo 121.121.2.2 &amp;gt;&amp;gt; greptarget&lt;BR /&gt;&lt;BR /&gt;# grep 1.1.1.1 greptarget&lt;BR /&gt;1.1.1.1&lt;BR /&gt;121.121.2.2&lt;BR /&gt;&lt;BR /&gt;# grep 1\.1\.1\.1 greptarget&lt;BR /&gt;1.1.1.1&lt;BR /&gt;121.121.2.2&lt;BR /&gt;&lt;BR /&gt;# grep -e '1\.1\.1\.1' greptarget&lt;BR /&gt;1.1.1.1&lt;BR /&gt;&lt;BR /&gt;So your THEIP variable will probably resolve to more than one possible target in /etc/hosts (probably not) ? &lt;BR /&gt;To be correct a logical expression ( -e ) with backslashed dots will be safe.&lt;BR /&gt;&lt;BR /&gt;2) I have a system here with an unconfigured token-ring card, that does not show up in lanscan, although it is visible in ioscan. ifconfig lan1 says the interface does not exist, although it is physically in the box,&lt;BR /&gt;and had been configuered years ago. This might be token-ring specific, but consider that diffrent physical lanX can behave diffrent from ethernet (FDDI ? other ...).&lt;BR /&gt;&lt;BR /&gt;3) If a box is configuered without LAN upon installation, and the network is configured later. The initial binding of the hostname is against the loopback interface (lo0:) which also does not appear in lanscan. Do not know if this makes any diffrence in your case.&lt;BR /&gt;&lt;BR /&gt;4) Your modification of /tmp/hosts will sort all comments to the top if I analyzed correctly. For me this would not be good, because I have several comment headers for diffrent networks like this&lt;BR /&gt;# net one&lt;BR /&gt;a.b.c.1&lt;BR /&gt;a.b.c.2&lt;BR /&gt;# net two&lt;BR /&gt;c.d.e.4&lt;BR /&gt;c.d.e.5&lt;BR /&gt;&lt;BR /&gt;Have a nice weekend&lt;BR /&gt;volker</description>
    <pubDate>Fri, 14 Jun 2002 14:42:46 GMT</pubDate>
    <dc:creator>Volker Borowski</dc:creator>
    <dc:date>2002-06-14T14:42:46Z</dc:date>
    <item>
      <title>/etc/hosts script required: quick one!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts-script-required-quick-one/m-p/2744842#M944334</link>
      <description>Hi all, back into my lab script creation time..&lt;BR /&gt;&lt;BR /&gt;I'm looking for a script (don't ask why ;)) that:&lt;BR /&gt;&lt;BR /&gt;1&amp;gt; checks for an undefined lan interface (can assume lan1 is free, but best to check)&lt;BR /&gt;ie: ifconfig lan1&lt;BR /&gt;if ERR&lt;BR /&gt;then &lt;BR /&gt;ifconfig lan1 192.168.1.1&lt;BR /&gt;else&lt;BR /&gt;ifconfig lan2&lt;BR /&gt;if ERR&lt;BR /&gt;then&lt;BR /&gt;ifconfig lan2 192.168.1.1&lt;BR /&gt;etc..&lt;BR /&gt;end&lt;BR /&gt;&lt;BR /&gt;2&amp;gt; after assigning this lan,&lt;BR /&gt;need to look at lan0 (that hostname is tied to - can assume 0..)&lt;BR /&gt;lets say it's 10.1.2.3&lt;BR /&gt;then grep the hostname /lan0 ip in /etc/hosts.&lt;BR /&gt;&lt;BR /&gt;3&amp;gt; /etc/hosts will then need to be modified to end up&lt;BR /&gt;with &lt;BR /&gt;192.168.1.1 hostname  hostalias&lt;BR /&gt;127.0.0.1 loopback localhost&lt;BR /&gt;10.1.2.3 hostname hostalias&lt;BR /&gt;&lt;BR /&gt;rather than the previous&lt;BR /&gt;127.0.0.1 loopback localhost&lt;BR /&gt;10.1.2.3 hostname hostalias&lt;BR /&gt;&lt;BR /&gt;+ all the rest of the stuff in /etc/hosts remaining.&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;Bill&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jun 2002 10:30:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts-script-required-quick-one/m-p/2744842#M944334</guid>
      <dc:creator>Bill McNAMARA_1</dc:creator>
      <dc:date>2002-06-14T10:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: /etc/hosts script required: quick one!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts-script-required-quick-one/m-p/2744843#M944335</link>
      <description>Bill&lt;BR /&gt;&lt;BR /&gt;I use the following to give the status of a lan, it can be modified to notify of an un-configured interface, one found then run through the config of this found interface, either pulling the info from the script, command line or config file.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Etc/hosts will have to have an annotation in it to distinguish Lan0  so that its info can be pulled.&lt;BR /&gt;&lt;BR /&gt;Just a few ideas.&lt;BR /&gt;&lt;BR /&gt;---------------------------------------------&lt;BR /&gt;#! /usr/bin/sh                                               &lt;BR /&gt;/usr/bin/uname -a                                            &lt;BR /&gt;/usr/sbin/lanscan                                            &lt;BR /&gt;ppas="0 1"                                                   &lt;BR /&gt;for ppa in $ppas                                             &lt;BR /&gt;do                                                           &lt;BR /&gt;stat=`/usr/sbin/lanadmin 2&amp;gt;/dev/null &amp;lt;&lt;EOF&gt;&lt;/EOF&gt;l                                                            &lt;BR /&gt;ppa $ppa                                                     &lt;BR /&gt;d                                                            &lt;BR /&gt;q                                                            &lt;BR /&gt;                                                             &lt;BR /&gt;EOF                                                          &lt;BR /&gt;`                                                            &lt;BR /&gt;echo $ppa --- $stat                                          &lt;BR /&gt;done                                            &lt;BR /&gt;----------------------------------------------&lt;BR /&gt;Paula&lt;BR /&gt;</description>
      <pubDate>Fri, 14 Jun 2002 11:02:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts-script-required-quick-one/m-p/2744843#M944335</guid>
      <dc:creator>Paula J Frazer-Campbell</dc:creator>
      <dc:date>2002-06-14T11:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: /etc/hosts script required: quick one!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts-script-required-quick-one/m-p/2744844#M944336</link>
      <description>managed to throw something together..&lt;BR /&gt;But would prefer a more elegant ip comparisson before changing!&lt;BR /&gt;&lt;BR /&gt;Still up for points!&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;#&lt;BR /&gt;# add the hostname to the /etc/hosts first&lt;BR /&gt;&lt;BR /&gt;THEIP=192.168.1.99&lt;BR /&gt;THEIP2=10.1.2.3&lt;BR /&gt;&lt;BR /&gt;for lan in $(lanscan | grep lan | awk {'print $5'})&lt;BR /&gt;do&lt;BR /&gt; ifconfig $lan 1&amp;gt;/dev/null 2&amp;gt;/dev/null&lt;BR /&gt; if [[ $? = 0 ]]; then&lt;BR /&gt; echo "&amp;gt; $lan used \c: "&lt;BR /&gt; #&lt;BR /&gt; # making sure IP not used already&lt;BR /&gt; #&lt;BR /&gt; ifconfig $lan | grep inet | awk {'print $2'} | grep $THEIP&lt;BR /&gt; if [[ $? = 0 ]]; then&lt;BR /&gt; echo "&amp;gt; $THEIP already in use here"&lt;BR /&gt; echo "&amp;gt; IP to set now $THEIP2"&lt;BR /&gt; THEIP=$THEIP2&lt;BR /&gt; fi&lt;BR /&gt;else&lt;BR /&gt; echo "&amp;gt; using $lan"&lt;BR /&gt; ifconfig $lan $THEIP&lt;BR /&gt; break&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;set -x&lt;BR /&gt;&lt;BR /&gt;grep \# /etc/hosts &amp;gt; /tmp/hosts&lt;BR /&gt;echo "$THEIP\t$(hostname)\t$(hostname)." &amp;gt;&amp;gt; /tmp/hosts&lt;BR /&gt;grep -v \# /etc/hosts &amp;gt;&amp;gt; /tmp/hosts</description>
      <pubDate>Fri, 14 Jun 2002 11:15:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts-script-required-quick-one/m-p/2744844#M944336</guid>
      <dc:creator>Bill McNAMARA_1</dc:creator>
      <dc:date>2002-06-14T11:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: /etc/hosts script required: quick one!</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts-script-required-quick-one/m-p/2744845#M944337</link>
      <description>Hi Bill,&lt;BR /&gt;&lt;BR /&gt;I do not know if you can rule out my thoughts because of your environment, but:&lt;BR /&gt;&lt;BR /&gt;1) a dot in a grep expression stands for a single character wildcard ! See this :&lt;BR /&gt;&lt;BR /&gt;# echo 1.1.1.1 &amp;gt; greptarget&lt;BR /&gt;# echo 121.121.2.2 &amp;gt;&amp;gt; greptarget&lt;BR /&gt;&lt;BR /&gt;# grep 1.1.1.1 greptarget&lt;BR /&gt;1.1.1.1&lt;BR /&gt;121.121.2.2&lt;BR /&gt;&lt;BR /&gt;# grep 1\.1\.1\.1 greptarget&lt;BR /&gt;1.1.1.1&lt;BR /&gt;121.121.2.2&lt;BR /&gt;&lt;BR /&gt;# grep -e '1\.1\.1\.1' greptarget&lt;BR /&gt;1.1.1.1&lt;BR /&gt;&lt;BR /&gt;So your THEIP variable will probably resolve to more than one possible target in /etc/hosts (probably not) ? &lt;BR /&gt;To be correct a logical expression ( -e ) with backslashed dots will be safe.&lt;BR /&gt;&lt;BR /&gt;2) I have a system here with an unconfigured token-ring card, that does not show up in lanscan, although it is visible in ioscan. ifconfig lan1 says the interface does not exist, although it is physically in the box,&lt;BR /&gt;and had been configuered years ago. This might be token-ring specific, but consider that diffrent physical lanX can behave diffrent from ethernet (FDDI ? other ...).&lt;BR /&gt;&lt;BR /&gt;3) If a box is configuered without LAN upon installation, and the network is configured later. The initial binding of the hostname is against the loopback interface (lo0:) which also does not appear in lanscan. Do not know if this makes any diffrence in your case.&lt;BR /&gt;&lt;BR /&gt;4) Your modification of /tmp/hosts will sort all comments to the top if I analyzed correctly. For me this would not be good, because I have several comment headers for diffrent networks like this&lt;BR /&gt;# net one&lt;BR /&gt;a.b.c.1&lt;BR /&gt;a.b.c.2&lt;BR /&gt;# net two&lt;BR /&gt;c.d.e.4&lt;BR /&gt;c.d.e.5&lt;BR /&gt;&lt;BR /&gt;Have a nice weekend&lt;BR /&gt;volker</description>
      <pubDate>Fri, 14 Jun 2002 14:42:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/etc-hosts-script-required-quick-one/m-p/2744845#M944337</guid>
      <dc:creator>Volker Borowski</dc:creator>
      <dc:date>2002-06-14T14:42:46Z</dc:date>
    </item>
  </channel>
</rss>

