<?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 question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2823892#M940263</link>
    <description>A couple of things to be aware of...&lt;BR /&gt;&lt;BR /&gt;You will need to use "groups username" or "groups -g username" instead of "groups -l username" if you don't use /etc/logingroups.&lt;BR /&gt;&lt;BR /&gt;If the user is not listed in /etc/group for his primary group (as specified in /etc/passwd), "groups -g" will not list the user's primary group.  "groups" and "id -Gn" will list the user's primary group.&lt;BR /&gt;&lt;BR /&gt;If you have su'ed to an account, "groups" without specifying the username will default to whom you logged in as, not the current username.  "id -Gn" defaults to the current username.&lt;BR /&gt;&lt;BR /&gt;Personally, I like:&lt;BR /&gt;id -Gn $user | grep groupname &amp;gt;/dev/null&lt;BR /&gt;if [ $? = 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo is a member of the group&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Darrell</description>
    <pubDate>Fri, 11 Oct 2002 13:39:17 GMT</pubDate>
    <dc:creator>Darrell Allen</dc:creator>
    <dc:date>2002-10-11T13:39:17Z</dc:date>
    <item>
      <title>scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2823885#M940256</link>
      <description>How would I go about scripting the following:&lt;BR /&gt;&lt;BR /&gt;IF $user IN group&lt;BR /&gt;THEN&lt;BR /&gt;FI&lt;BR /&gt;&lt;BR /&gt;Where group is on of the groups in /etc/group?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance!</description>
      <pubDate>Fri, 11 Oct 2002 12:54:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2823885#M940256</guid>
      <dc:creator>Michele Macintire</dc:creator>
      <dc:date>2002-10-11T12:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2823886#M940257</link>
      <description>Not sure what you're asking, but:&lt;BR /&gt;&lt;BR /&gt;GROUP=dba&lt;BR /&gt;USER=michele&lt;BR /&gt;&lt;BR /&gt;ISIT=`cat /etc/group | grep "^$GROUP:" | grep $USER`&lt;BR /&gt;&lt;BR /&gt;if [ "${ISIT}" != '' ]&lt;BR /&gt;  then&lt;BR /&gt;&lt;BR /&gt;   echo "$USER in $GROUP&lt;BR /&gt;&lt;BR /&gt;  else&lt;BR /&gt;   &lt;BR /&gt;   echo "$USER not in $GROUP"&lt;BR /&gt;&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 11 Oct 2002 13:03:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2823886#M940257</guid>
      <dc:creator>Charles McCary</dc:creator>
      <dc:date>2002-10-11T13:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2823887#M940258</link>
      <description>Why bother ? You can use the "groups" command to find out which group a valid username belongs to. For example..&lt;BR /&gt;# groups -l skchan&lt;BR /&gt;will list all groups to which user "skchan" belongs to. Isn't that what you wanted ?&lt;BR /&gt;</description>
      <pubDate>Fri, 11 Oct 2002 13:04:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2823887#M940258</guid>
      <dc:creator>S.K. Chan</dc:creator>
      <dc:date>2002-10-11T13:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2823888#M940259</link>
      <description>You can try like this&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;export A=` cat /etc/group | grep $user | wc -l `&lt;BR /&gt;&lt;BR /&gt;if [ $A = 1 ]&lt;BR /&gt;then&lt;BR /&gt;&lt;BR /&gt;command&lt;BR /&gt;&lt;BR /&gt;exit&lt;BR /&gt;&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;2nd command&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Manoj Srivastava</description>
      <pubDate>Fri, 11 Oct 2002 13:06:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2823888#M940259</guid>
      <dc:creator>MANOJ SRIVASTAVA</dc:creator>
      <dc:date>2002-10-11T13:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2823889#M940260</link>
      <description>I agree, the group command is probably the easier way to go.</description>
      <pubDate>Fri, 11 Oct 2002 13:07:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2823889#M940260</guid>
      <dc:creator>Charles McCary</dc:creator>
      <dc:date>2002-10-11T13:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2823890#M940261</link>
      <description>use the id -G or id -nG (as root) to get the group of a specific user&lt;BR /&gt;&lt;BR /&gt;man id for more information&lt;BR /&gt;&lt;BR /&gt;Jean-Luc</description>
      <pubDate>Fri, 11 Oct 2002 13:07:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2823890#M940261</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2002-10-11T13:07:18Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2823891#M940262</link>
      <description>The groups command has one other advantage that you have overlooked. It will also work in an NIS and NIS+ environment as well as the vanilla /etc/group world.&lt;BR /&gt;</description>
      <pubDate>Fri, 11 Oct 2002 13:11:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2823891#M940262</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2002-10-11T13:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2823892#M940263</link>
      <description>A couple of things to be aware of...&lt;BR /&gt;&lt;BR /&gt;You will need to use "groups username" or "groups -g username" instead of "groups -l username" if you don't use /etc/logingroups.&lt;BR /&gt;&lt;BR /&gt;If the user is not listed in /etc/group for his primary group (as specified in /etc/passwd), "groups -g" will not list the user's primary group.  "groups" and "id -Gn" will list the user's primary group.&lt;BR /&gt;&lt;BR /&gt;If you have su'ed to an account, "groups" without specifying the username will default to whom you logged in as, not the current username.  "id -Gn" defaults to the current username.&lt;BR /&gt;&lt;BR /&gt;Personally, I like:&lt;BR /&gt;id -Gn $user | grep groupname &amp;gt;/dev/null&lt;BR /&gt;if [ $? = 0 ]&lt;BR /&gt;then&lt;BR /&gt;echo is a member of the group&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Darrell</description>
      <pubDate>Fri, 11 Oct 2002 13:39:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2823892#M940263</guid>
      <dc:creator>Darrell Allen</dc:creator>
      <dc:date>2002-10-11T13:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2823893#M940264</link>
      <description>Well, I needed something that I could put in a script to say if a user was in this group, do one thing and if not, skip it.&lt;BR /&gt;&lt;BR /&gt;I've tried the "id -nG username" command and don't get any results, even if I use a username that I can clearly see in /etc/group as belonging to a group.&lt;BR /&gt;&lt;BR /&gt;The cat /etc/group works for me.  I guess I was thinking too complicated to not think of something so simple!  &lt;BR /&gt;&lt;BR /&gt;Thank you all for helping me with my mental block!&lt;BR /&gt;&lt;BR /&gt;Michele</description>
      <pubDate>Fri, 11 Oct 2002 13:53:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/2823893#M940264</guid>
      <dc:creator>Michele Macintire</dc:creator>
      <dc:date>2002-10-11T13:53:39Z</dc:date>
    </item>
  </channel>
</rss>

