<?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: Issue obtaining the users IP in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396316#M706041</link>
    <description>If it's in a cgi script, why not just query the environment variable REMOTE_ADDR, which is passed as standard via CGI?</description>
    <pubDate>Fri, 08 Oct 2004 08:42:57 GMT</pubDate>
    <dc:creator>Simon Hargrave</dc:creator>
    <dc:date>2004-10-08T08:42:57Z</dc:date>
    <item>
      <title>Issue obtaining the users IP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396315#M706040</link>
      <description>I have a situation in a script called from a web page that uses the following statement:&lt;BR /&gt;&lt;BR /&gt;/usr/bin/who -u | /usr/bin/grep `/usr/bin/who -m -R | /usr/bin/awk '{ print $2 }'`" " | /usr/bin/awk '{ print $8 }' | /usr/bin/nsl&lt;BR /&gt;ookup | /usr/bin/grep Address | /usr/bin/awk '{ print $2 }'&lt;BR /&gt;&lt;BR /&gt;This script works great for anyone logged in on a normal terminal session. However, when called by a script from a web page via a cgi script I get the following response:&lt;BR /&gt;&lt;BR /&gt;"process not attached to terminal"&lt;BR /&gt;&lt;BR /&gt;I know it bombing at the "who -m". Problem is I can not figure out how to get around this issue.&lt;BR /&gt;&lt;BR /&gt;Does any one have any idea how to obtain the IP address from a connection where the process is not attached to a terminal session?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 08 Oct 2004 08:40:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396315#M706040</guid>
      <dc:creator>Jay LaBonte</dc:creator>
      <dc:date>2004-10-08T08:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Issue obtaining the users IP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396316#M706041</link>
      <description>If it's in a cgi script, why not just query the environment variable REMOTE_ADDR, which is passed as standard via CGI?</description>
      <pubDate>Fri, 08 Oct 2004 08:42:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396316#M706041</guid>
      <dc:creator>Simon Hargrave</dc:creator>
      <dc:date>2004-10-08T08:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: Issue obtaining the users IP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396317#M706042</link>
      <description>Because the http server in use at this customer site is a home grown server, and it does not have REMOTE_ADDR available. (Beleive me I have asked them to switch to another http server like apache, but that have to must custom code to convert, so Im stuck with the situation)&lt;BR /&gt;&lt;BR /&gt;So now that that is out of the way, any real suggestions?</description>
      <pubDate>Fri, 08 Oct 2004 08:48:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396317#M706042</guid>
      <dc:creator>Jay LaBonte</dc:creator>
      <dc:date>2004-10-08T08:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Issue obtaining the users IP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396318#M706043</link>
      <description>Well in that case you probably don't have an option.  The connection to the "shell" will not be from the connecting user, rather it will be from the httpd itself.  That is, if you could get the IP address of "whatever ran the who command", this would always be the same, ie the IP address of the server the httpd daemon is running.  The only thing that knows the connecting address is the http daemon itself.  It it doesn't pass the information that it should, you can't extract it.</description>
      <pubDate>Fri, 08 Oct 2004 09:24:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396318#M706043</guid>
      <dc:creator>Simon Hargrave</dc:creator>
      <dc:date>2004-10-08T09:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Issue obtaining the users IP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396319#M706044</link>
      <description>Acually there is no httpd is this situation. The way they have it set up is throught inetd.conf and services.&lt;BR /&gt;&lt;BR /&gt;The services entry specifies: UniHTTP 8080&lt;BR /&gt;&lt;BR /&gt;Then in the inetd.conf file they have the following entry:&lt;BR /&gt;&lt;BR /&gt;UniHTTP stream tcp nowait root /opt/acc/ud/bin/http.sh http.sh&lt;BR /&gt;&lt;BR /&gt;http.sh then calls a 'C' routine that lanches an application within their database environment.&lt;BR /&gt;&lt;BR /&gt;So the actual deamon performing the call is inetd. Is there anyway of extracting the IP from inetd or getting inetd to append the IP to the shell call as a parameter?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 08 Oct 2004 10:29:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396319#M706044</guid>
      <dc:creator>Jay LaBonte</dc:creator>
      <dc:date>2004-10-08T10:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: Issue obtaining the users IP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396320#M706045</link>
      <description>Your inetd script as,&lt;BR /&gt;&lt;BR /&gt;UniHTTP stream tcp nowait root /opt/acc/ud/bin/http.sh http.sh&lt;BR /&gt;&lt;BR /&gt;You can send parameter to that script as,&lt;BR /&gt;&lt;BR /&gt; UniHTTP stream tcp nowait root /opt/acc/ud/bin/http.sh http.sh `shell action to get ip there and send it there`&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; And your try as,&lt;BR /&gt;/usr/bin/who -u | /usr/bin/grep `/usr/bin/who -m -R | /usr/bin/awk '{ print $2 }'`" " | /usr/bin/awk '{ print $8 }' | /usr/bin/nsl&lt;BR /&gt;ookup | /usr/bin/grep Address | /usr/bin/awk '{ print $2 }'&lt;BR /&gt;&lt;BR /&gt; seems to be very strange there.&lt;BR /&gt;&lt;BR /&gt; you can use getip command here.&lt;BR /&gt;&lt;BR /&gt; getip &lt;HOSTNAME&gt;&lt;BR /&gt;&lt;BR /&gt; So you can get the remote ip-address as,&lt;BR /&gt; &lt;BR /&gt;  getip `who -mR | awk '{ print $6 }' | tr -d '()'`&lt;BR /&gt;&lt;BR /&gt; It will give the IP-Address there easily.&lt;BR /&gt;&lt;BR /&gt;HTH.&lt;BR /&gt;&lt;BR /&gt;&lt;/HOSTNAME&gt;</description>
      <pubDate>Fri, 08 Oct 2004 11:59:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396320#M706045</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-10-08T11:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: Issue obtaining the users IP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396321#M706046</link>
      <description>Well i like the script for obtaining the ip, however it does not perform the command inside the `` is simply hands the command over the shell script without executing.</description>
      <pubDate>Fri, 08 Oct 2004 12:57:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396321#M706046</guid>
      <dc:creator>Jay LaBonte</dc:creator>
      <dc:date>2004-10-08T12:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: Issue obtaining the users IP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396322#M706047</link>
      <description>Is  getip `who -mR | awk '{ print $6 }' | tr -d '()'` not working there?&lt;BR /&gt;&lt;BR /&gt;can you verify step by step as,&lt;BR /&gt;&lt;BR /&gt;1. IP=$(who -mR | awk '{ print $6 }' | tr -d '()')&lt;BR /&gt;2. getip $IP&lt;BR /&gt;&lt;BR /&gt;Try to execute with full path of getip , who there. You can that with which getip / which who there. Post your problem with your try again.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Muthukumar.</description>
      <pubDate>Wed, 13 Oct 2004 06:50:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396322#M706047</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-10-13T06:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: Issue obtaining the users IP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396323#M706048</link>
      <description>The simplest way to find the address from who is to NEVER count fields or characters. The IP address is always the last field:&lt;BR /&gt; &lt;BR /&gt;IP=$(who -mu | awk '{print $NF}'&lt;BR /&gt;&lt;BR /&gt;The answer is that your process is not attached to a terminal. Just like cron or at, inetd has no terminal and therefore an IP address is meaningless. You'll have to extract the adress for the web page from your web server as who does not understand web pages (no Unix login).</description>
      <pubDate>Wed, 13 Oct 2004 08:08:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396323#M706048</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2004-10-13T08:08:11Z</dc:date>
    </item>
    <item>
      <title>Re: Issue obtaining the users IP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396324#M706049</link>
      <description>The problem isn't that the getip statement is breaking down at some point. The problem is, inetd is not processing the statement between the tics, `who -mR | awk '{ print $6 }' | tr -d '()'`.&lt;BR /&gt;&lt;BR /&gt;inetd is passing the statement to the target program as a parameter, without evaluating the statement first.&lt;BR /&gt;&lt;BR /&gt;As a result the target script will see $x value as follows:&lt;BR /&gt;$1 = `who&lt;BR /&gt;$2 = -mR&lt;BR /&gt;$3 = |&lt;BR /&gt;$4 = awk&lt;BR /&gt;etc...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 13 Oct 2004 08:15:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396324#M706049</guid>
      <dc:creator>Jay LaBonte</dc:creator>
      <dc:date>2004-10-13T08:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: Issue obtaining the users IP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396325#M706050</link>
      <description>Okay, I have another plan, which stems from some work I've had to do recently.&lt;BR /&gt;&lt;BR /&gt;Not sure why your backticks don't work, but the who command won't work anyway because you're not attached to a tty.&lt;BR /&gt;&lt;BR /&gt;So, I got thinking about this, and you can do it with the lsof command.  ( you can download lsof from &lt;A href="http://hpux.connect.org.uk/hppd/hpux/Sysadmin/lsof-4.72/" target="_blank"&gt;http://hpux.connect.org.uk/hppd/hpux/Sysadmin/lsof-4.72/&lt;/A&gt; )&lt;BR /&gt;&lt;BR /&gt;Basically the theory is, you run lsof against your own process, and extract the line that says what STDIN (stream 1) is attached to.  This will be an inet entry which will show the source and destination ip/ports.  You can then extract these.&lt;BR /&gt;&lt;BR /&gt;In your example, I'd suggest adding the following line to httpd.sh: -&lt;BR /&gt;&lt;BR /&gt;IP=$(/usr/bin/getip $(/usr/local/bin/lsof -p $$ | grep -w "1u" | cut -d\&amp;gt; -f2 | cut -d: -f1))&lt;BR /&gt;&lt;BR /&gt;You can then pass $IP to your binary as a parameter.&lt;BR /&gt;&lt;BR /&gt;Perhaps first verify it's working with echo $IP &amp;gt;&amp;gt; /tmp/http.access.log and make sure that file gets filled with IP addresses as you access the service.&lt;BR /&gt;&lt;BR /&gt;I used this in a wrapper script to log connections to inetd services that aren't clever enough to log connection attempts.  I basically run a wrapper which writes ip address, date, service etc to a logfile, then pass through to the actual server daemon process.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 13 Oct 2004 10:02:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396325#M706050</guid>
      <dc:creator>Simon Hargrave</dc:creator>
      <dc:date>2004-10-13T10:02:36Z</dc:date>
    </item>
    <item>
      <title>Re: Issue obtaining the users IP</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396326#M706051</link>
      <description>Thank You!&lt;BR /&gt;&lt;BR /&gt;The lsof gave me excactly what I needed.&lt;BR /&gt;&lt;BR /&gt;Thanks Again.&lt;BR /&gt;Jay</description>
      <pubDate>Wed, 13 Oct 2004 10:22:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/issue-obtaining-the-users-ip/m-p/3396326#M706051</guid>
      <dc:creator>Jay LaBonte</dc:creator>
      <dc:date>2004-10-13T10:22:28Z</dc:date>
    </item>
  </channel>
</rss>

