<?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: Scripting Challenge in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112292#M708752</link>
    <description>I think even if you lack lsof there is some hope.&lt;BR /&gt;At least you could narrow possible telnet sockets by parsing netstat with something like&lt;BR /&gt; &lt;BR /&gt;# netstat -anfinet|awk '$4~/\.23$/{print$5}'&lt;BR /&gt; &lt;BR /&gt;will list foreign IPs of telnet sockets.&lt;BR /&gt;The least we know is the port they connected trhough.&lt;BR /&gt;netstat also give the local IPs which are the 4th column and should correspond to your MC/SG packages' IPs.</description>
    <pubDate>Thu, 06 Nov 2003 10:55:38 GMT</pubDate>
    <dc:creator>Ralph Grothe</dc:creator>
    <dc:date>2003-11-06T10:55:38Z</dc:date>
    <item>
      <title>Scripting Challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112280#M708740</link>
      <description>Howdy Everyone,&lt;BR /&gt;&lt;BR /&gt;I have a scripting problem that I can't quite get solved.&lt;BR /&gt;&lt;BR /&gt;We have an MC/SG environment and I need a script that I can run when users log in that will somehow determine the MC/SG package they are telnet'ing and based on the package set some environment variables for their session.  &lt;BR /&gt;&lt;BR /&gt;I have written a script that generally works, but the problem I am having is that this must also work if a user uses 'su' to switch to a different user.&lt;BR /&gt;&lt;BR /&gt;Any and all suggestions welcome!&lt;BR /&gt;</description>
      <pubDate>Thu, 06 Nov 2003 09:51:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112280#M708740</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2003-11-06T09:51:55Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112281#M708741</link>
      <description>Patrick, &lt;BR /&gt;&lt;BR /&gt;It was all going so well until your last sentence.  It must work with "su".  I take you mean that we can't guarantee .profile is going to get run?</description>
      <pubDate>Thu, 06 Nov 2003 10:03:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112281#M708741</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2003-11-06T10:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112282#M708742</link>
      <description>hi&lt;BR /&gt;i thing you try "su user", if yes try the following:&lt;BR /&gt;&lt;BR /&gt;su - user</description>
      <pubDate>Thu, 06 Nov 2003 10:07:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112282#M708742</guid>
      <dc:creator>TSaliba</dc:creator>
      <dc:date>2003-11-06T10:07:39Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112283#M708743</link>
      <description>Patrick,&lt;BR /&gt;&lt;BR /&gt;How about replacing "su" with a script that invokes the real "su" - with the - option?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Pete&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;</description>
      <pubDate>Thu, 06 Nov 2003 10:08:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112283#M708743</guid>
      <dc:creator>Pete Randall</dc:creator>
      <dc:date>2003-11-06T10:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112284#M708744</link>
      <description>Not sure about the issue.&lt;BR /&gt;&lt;BR /&gt;Are you trying to figure out who is the user originally ?&lt;BR /&gt;whoami vs who am i ?&lt;BR /&gt;&lt;BR /&gt;Rgds,&lt;BR /&gt;JL</description>
      <pubDate>Thu, 06 Nov 2003 10:09:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112284#M708744</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2003-11-06T10:09:55Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112285#M708745</link>
      <description>When using the telnetting, it is doable by using the tty which relates to a telnetd which could be related to a lsof which gives the IP adress the connection was to. This is a save method as using the who -R and using the from address to find the to address in netstat, because a user could open several sessions from the save host.&lt;BR /&gt;pid=$(ps -t$(tty |sed 's|/dev/||') | grep telnetd | awk '{print $1}')&lt;BR /&gt;[ -n "$pid" ] &amp;amp;&amp;amp; lsof -p $pid | grep TCP | sed 's|^.*&amp;gt;\(.*\):.*$|\1|' | uniq&lt;BR /&gt;&lt;BR /&gt;But with the su, I, not sure I understand what you want. If you want the same effect as with the telnetting, it would work here to.&lt;BR /&gt;&lt;BR /&gt;Another way, which we use, is give users a homedirectory in the package. Then it is easy to do. But this only works if a user is package specific. Which is apparently not your case.&lt;BR /&gt;&lt;BR /&gt;Hope this helps you solve the problem.&lt;BR /&gt;</description>
      <pubDate>Thu, 06 Nov 2003 10:10:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112285#M708745</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2003-11-06T10:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112286#M708746</link>
      <description>For su, you can use ps to find out who's using the pty;&lt;BR /&gt; &lt;BR /&gt;# ps -t `basename \`tty\`` -ouser&lt;BR /&gt; &lt;BR /&gt;USER&lt;BR /&gt;root&lt;BR /&gt;cw16791n&lt;BR /&gt;root&lt;BR /&gt;&lt;BR /&gt;If more than 2 entries are returned, you know that it's the USER header, the original id and any su id.&lt;BR /&gt;&lt;BR /&gt;Chris.</description>
      <pubDate>Thu, 06 Nov 2003 10:11:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112286#M708746</guid>
      <dc:creator>Chris Wilshaw</dc:creator>
      <dc:date>2003-11-06T10:11:26Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112287#M708747</link>
      <description>OK, sorry folks.  When I said "must also work is a user uses su..." I did mean that they would use 'su - username' to switch users.&lt;BR /&gt;&lt;BR /&gt;My big problem, even with 'su - user' is how do you tell what package name / IP they connected to originally?</description>
      <pubDate>Thu, 06 Nov 2003 10:12:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112287#M708747</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2003-11-06T10:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112288#M708748</link>
      <description>I would use `logname` or $LOGNAME.&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;$id&lt;BR /&gt;uid=222(dba) gid=201(...)&lt;BR /&gt;$ su informix&lt;BR /&gt;Password:&lt;BR /&gt;$ echo $LOGNAME&lt;BR /&gt;dba&lt;BR /&gt;$ echo `logname`&lt;BR /&gt;dba&lt;BR /&gt;$ exit&lt;BR /&gt;$ su - informix&lt;BR /&gt;Password:&lt;BR /&gt;...&lt;BR /&gt;$ echo $LOGNAME&lt;BR /&gt;dba&lt;BR /&gt;$ echo `logname`&lt;BR /&gt;dba&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 06 Nov 2003 10:12:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112288#M708748</guid>
      <dc:creator>Steve Lewis</dc:creator>
      <dc:date>2003-11-06T10:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112289#M708749</link>
      <description>A rather easy answer is to set up an alias for su that is actually su='su - '.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 06 Nov 2003 10:13:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112289#M708749</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2003-11-06T10:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112290#M708750</link>
      <description>Thinking about it, I do not think it's possible like this.  The ip you connected to is just not available anywhere.  Even if you wrote your own telnetd and listened on the port yourself, you still wouldn't be able to tell what ip address they connected to. Maybe some tcp/ip sniffer could read the packet headers to get the destination address but I don't think that is going to be a script.&lt;BR /&gt; &lt;BR /&gt;</description>
      <pubDate>Thu, 06 Nov 2003 10:35:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112290#M708750</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2003-11-06T10:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112291#M708751</link>
      <description>I'm not sure if this is of any help?&lt;BR /&gt; &lt;BR /&gt;You can track the PID of the login shell that issued the "su - someone" by putting something like this in .profile&lt;BR /&gt; &lt;BR /&gt;ORIG_SHELL=$(UNIX95= ps -o ppid= -p $$)&lt;BR /&gt; &lt;BR /&gt;With this PID you could further track the associated pseudo terminal an try to match with output from "who -u".&lt;BR /&gt; &lt;BR /&gt;If you have lsof on the box I guess you could even track down the sockets used by the telnetd that served the login which uses the pty.</description>
      <pubDate>Thu, 06 Nov 2003 10:49:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112291#M708751</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2003-11-06T10:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112292#M708752</link>
      <description>I think even if you lack lsof there is some hope.&lt;BR /&gt;At least you could narrow possible telnet sockets by parsing netstat with something like&lt;BR /&gt; &lt;BR /&gt;# netstat -anfinet|awk '$4~/\.23$/{print$5}'&lt;BR /&gt; &lt;BR /&gt;will list foreign IPs of telnet sockets.&lt;BR /&gt;The least we know is the port they connected trhough.&lt;BR /&gt;netstat also give the local IPs which are the 4th column and should correspond to your MC/SG packages' IPs.</description>
      <pubDate>Thu, 06 Nov 2003 10:55:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112292#M708752</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2003-11-06T10:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112293#M708753</link>
      <description>who -um will return the IP address of the client telnet connection, even if you su or su -&lt;BR /&gt;&lt;BR /&gt;mark</description>
      <pubDate>Thu, 06 Nov 2003 11:20:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112293#M708753</guid>
      <dc:creator>Mark Greene_1</dc:creator>
      <dc:date>2003-11-06T11:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112294#M708754</link>
      <description>Elmar's trick got me going in the right directions.  His code snippets  produced the machine that the telnet was originating from , but it was fairly simple to get the address that the telnet was going to from the lsof output.  &lt;BR /&gt;&lt;BR /&gt;I wound up doing this to get the package name the user telnet'ed to (and this still worked when the user did a 'su - username' to switch user):&lt;BR /&gt;&lt;BR /&gt;PID=$(ps -t $(tty |sed 's|/dev/||') | grep telnetd | awk '{print $1}')&lt;BR /&gt;&lt;BR /&gt;TOPACKAGE=$([ -n "$PID" ] &amp;amp;&amp;amp; /usr/local/bin/lsof -p $PID | grep TCP | awk '{print $9}' | awk -F : '{print $1}' | awk -F . '{print $1}' | uniq)&lt;BR /&gt;&lt;BR /&gt;The last 3 awk statements is my crude way of getting the name of the package (without the domain name) the user telnet'ed to.  I'm sure there is a better way to do it, but this works for me.&lt;BR /&gt;&lt;BR /&gt;Man I LOVE these forums.</description>
      <pubDate>Thu, 06 Nov 2003 11:42:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112294#M708754</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2003-11-06T11:42:20Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting Challenge</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112295#M708755</link>
      <description>I realized I got the wrong IP address from the lsof output the moment I left the building here... Sorry.&lt;BR /&gt;I was thinking about calling someone to put it right (and score some points) but thought you would be able to do this too.&lt;BR /&gt;&lt;BR /&gt;Happy it solved your problem.&lt;BR /&gt;</description>
      <pubDate>Fri, 07 Nov 2003 01:05:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-challenge/m-p/3112295#M708755</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2003-11-07T01:05:56Z</dc:date>
    </item>
  </channel>
</rss>

