<?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 help... in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3634539#M808173</link>
    <description>B.Mahendra Kumar,&lt;BR /&gt;&lt;BR /&gt;Nice script!  I made a copy for future use.  This script requires a "trusted" system architecture.  Mine aren't, currently...but will be in a few months.&lt;BR /&gt;&lt;BR /&gt;Dwyane</description>
    <pubDate>Tue, 27 Sep 2005 09:49:46 GMT</pubDate>
    <dc:creator>Dwyane Everts_1</dc:creator>
    <dc:date>2005-09-27T09:49:46Z</dc:date>
    <item>
      <title>Scripting help...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3634530#M808164</link>
      <description>Hi, gang...&lt;BR /&gt;&lt;BR /&gt;I'm needing some help writing a script.  For security reasons, I have to extract some info from /etc/passwd so the user acct manager can verify it against the application user accounts.  I guess they got out of sync somehow.  Anyway,  I need a script to do the following:&lt;BR /&gt;&lt;BR /&gt;1.  Extract fields 1, 2, 4, and 5 from /etc/passwd.&lt;BR /&gt;2.  Convert field 2 (password) into "Deactivated," "Activated," or "Blank."&lt;BR /&gt;3.  Remove the system accounts from the final list.&lt;BR /&gt;&lt;BR /&gt;Sounds easy enough, but I'm having a difficult time getting awk and cut to work in a desirable way.&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;Dwyane</description>
      <pubDate>Mon, 26 Sep 2005 06:17:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3634530#M808164</guid>
      <dc:creator>Dwyane Everts_1</dc:creator>
      <dc:date>2005-09-26T06:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting help...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3634531#M808165</link>
      <description>This takes care of  all requirements.&lt;BR /&gt;&lt;BR /&gt;for i in $(logins -u|awk '{print 1}')&lt;BR /&gt;do&lt;BR /&gt;grep -i $i /etc/passwd| awk -F : '{print $1," ",$4,$5}'&lt;BR /&gt;done</description>
      <pubDate>Mon, 26 Sep 2005 06:24:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3634531#M808165</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2005-09-26T06:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting help...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3634532#M808166</link>
      <description>You can do with awk / perl or cut + scripting easily. However, how to do the second requirement of,&lt;BR /&gt;&lt;BR /&gt;Convert field 2 (password) into "Deactivated," "Activated," or "Blank."&lt;BR /&gt;&lt;BR /&gt;based on passwd -s &lt;ACCOUNT&gt;&lt;BR /&gt;&lt;BR /&gt;or ?&lt;BR /&gt;&lt;BR /&gt;It will return only PS=passworded; LK=locked; and NP=no  password.&lt;BR /&gt;&lt;BR /&gt;Get back to get suitable script promptly.&lt;BR /&gt;&lt;BR /&gt;hth.&lt;/ACCOUNT&gt;</description>
      <pubDate>Mon, 26 Sep 2005 06:27:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3634532#M808166</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-09-26T06:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting help...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3634533#M808167</link>
      <description>To make the second tab to blank then,&lt;BR /&gt;&lt;BR /&gt;# cp -p /etc/passwd /etc/passwd.bak&lt;BR /&gt;# grep -E "$(logins -u | awk '{ printf $1"|";} END { printf " " }')" /etc/passwd | awk -F":" '{ print $1," ",$4,$5 }'&lt;BR /&gt;&lt;BR /&gt;hth.</description>
      <pubDate>Mon, 26 Sep 2005 06:46:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3634533#M808167</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-09-26T06:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting help...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3634534#M808168</link>
      <description>You can use this as,&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;# script.ksh&lt;BR /&gt;for user in `logins -u | cut -d" " -f1`&lt;BR /&gt;do&lt;BR /&gt;   &lt;BR /&gt;   status=$(passwd -s $user | cut -d " " -f3)&lt;BR /&gt;   &lt;BR /&gt;   case $status in&lt;BR /&gt;     NP) &lt;BR /&gt;     code="blank";&lt;BR /&gt;     ;;&lt;BR /&gt;     LK) &lt;BR /&gt;     code="Deactivated";&lt;BR /&gt;     ;;&lt;BR /&gt;     PS)&lt;BR /&gt;     code="Activated";&lt;BR /&gt;     ;;&lt;BR /&gt;   esac&lt;BR /&gt;      &lt;BR /&gt;   grep $user /etc/passwd | awk -F ":" -v var=$code '{ print $1,var,$4,$5 }'&lt;BR /&gt;   &lt;BR /&gt;done   &lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;# END #&lt;BR /&gt;&lt;BR /&gt;# chmod u+x script.ksh&lt;BR /&gt;# ./script.ksh&lt;BR /&gt;&lt;BR /&gt;# Ouput #&lt;BR /&gt;smbnull Deactivated 101 DO NOT USE OR DELETE - needed by Samba&lt;BR /&gt;mysql Deactivated 102&lt;BR /&gt;iwww Deactivated 1&lt;BR /&gt;owww Deactivated 1&lt;BR /&gt;muthu blank 20&lt;BR /&gt;&lt;BR /&gt;hth.&lt;BR /&gt;</description>
      <pubDate>Mon, 26 Sep 2005 06:57:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3634534#M808168</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2005-09-26T06:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting help...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3634535#M808169</link>
      <description>Just a note :&lt;BR /&gt;to grep on /etc/passwd&lt;BR /&gt;&lt;BR /&gt;say "user" is the variable&lt;BR /&gt;grep ^${user}":" /etc/passwd&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Jean-Luc&lt;BR /&gt;</description>
      <pubDate>Mon, 26 Sep 2005 07:10:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3634535#M808169</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2005-09-26T07:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting help...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3634536#M808170</link>
      <description>Hi Dwyane:&lt;BR /&gt;&lt;BR /&gt;Try this:&lt;BR /&gt;&lt;BR /&gt;# logins -uxo|perl -aF":" -ne 'printf("%10s %2s %3d %s\n",$F[0],$F[7],$F[3],$F[4]) if $F[1] &amp;gt; 100' -   &lt;BR /&gt;&lt;BR /&gt;The logins() utility shows PS for a valid password; LK for locked and NP for no password.  These appear in the output above.&lt;BR /&gt;&lt;BR /&gt;By limiting users to those with UID &amp;gt; 100, you effectively get (by default) a list without system users.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 26 Sep 2005 07:22:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3634536#M808170</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2005-09-26T07:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting help...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3634537#M808171</link>
      <description>It's amazing how requirements change when you start a project.  Here is the final solution:&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;# set -x&lt;BR /&gt;&lt;BR /&gt;&amp;gt; /tmp/passwd.bak&lt;BR /&gt;&lt;BR /&gt;for user in `logins -uo | cut -d":" -f1`&lt;BR /&gt;        do&lt;BR /&gt;        status=$(passwd -s $user | cut -d " " -f3)&lt;BR /&gt;                case $status in&lt;BR /&gt;&lt;BR /&gt;                NP)&lt;BR /&gt;                code="BLANK";&lt;BR /&gt;                ;;&lt;BR /&gt;&lt;BR /&gt;                LK)&lt;BR /&gt;                code="DEACT";&lt;BR /&gt;                ;;&lt;BR /&gt;&lt;BR /&gt;                PS)&lt;BR /&gt;                code="ACT";&lt;BR /&gt;                ;;&lt;BR /&gt;&lt;BR /&gt;                esac&lt;BR /&gt;        grep $user /etc/passwd | awk -F ":" -v var=$code '{ print $1," : ",var,"&lt;BR /&gt; : ",$5 }' &amp;gt;&amp;gt; /tmp/passwd.bak&lt;BR /&gt;        done&lt;BR /&gt;#       cat /tmp/passwd.bak&lt;BR /&gt;&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks to all for your help!&lt;BR /&gt;&lt;BR /&gt;Dwyane</description>
      <pubDate>Mon, 26 Sep 2005 09:38:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3634537#M808171</guid>
      <dc:creator>Dwyane Everts_1</dc:creator>
      <dc:date>2005-09-26T09:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting help...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3634538#M808172</link>
      <description>Dwyane,&lt;BR /&gt;&lt;BR /&gt;I hope this will be useful for you, I have taken this from the ITRC Forms...But it was helpful for me, You can put some more for your active accounts in this script.</description>
      <pubDate>Tue, 27 Sep 2005 04:48:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3634538#M808172</guid>
      <dc:creator>B.Mahendra Kumar_2</dc:creator>
      <dc:date>2005-09-27T04:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting help...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3634539#M808173</link>
      <description>B.Mahendra Kumar,&lt;BR /&gt;&lt;BR /&gt;Nice script!  I made a copy for future use.  This script requires a "trusted" system architecture.  Mine aren't, currently...but will be in a few months.&lt;BR /&gt;&lt;BR /&gt;Dwyane</description>
      <pubDate>Tue, 27 Sep 2005 09:49:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-help/m-p/3634539#M808173</guid>
      <dc:creator>Dwyane Everts_1</dc:creator>
      <dc:date>2005-09-27T09:49:46Z</dc:date>
    </item>
  </channel>
</rss>

