<?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/3467354#M849157</link>
    <description>&lt;BR /&gt;one more&lt;BR /&gt;&lt;BR /&gt;#cat /etc/passwd |awk -F: '{print $1}' &amp;gt; file&lt;BR /&gt;&lt;BR /&gt;for user in 'cat file'&lt;BR /&gt;do&lt;BR /&gt;echo " Do you want $user to be deleted"&lt;BR /&gt;read x&lt;BR /&gt;if ($x==y)&lt;BR /&gt;userdel -r $user&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;</description>
    <pubDate>Thu, 20 Jan 2005 06:06:11 GMT</pubDate>
    <dc:creator>Ravi_8</dc:creator>
    <dc:date>2005-01-20T06:06:11Z</dc:date>
    <item>
      <title>Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467347#M849150</link>
      <description>Dear admins,&lt;BR /&gt;&lt;BR /&gt;I need to clean up a passwd file ( 150 dormant accounts). I have the list of user ids to be removed. Does anyone have a sed/perl script written for this purpose? It's not a secure OS yet, so I can edit the /etc/passwd file directly.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Kumar</description>
      <pubDate>Thu, 20 Jan 2005 05:22:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467347#M849150</guid>
      <dc:creator>Sivasingam Santhakumar</dc:creator>
      <dc:date>2005-01-20T05:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467348#M849151</link>
      <description>Hi,&lt;BR /&gt;how about:&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;while read record&lt;BR /&gt;do&lt;BR /&gt;userdel -r $record&lt;BR /&gt;done &amp;lt; list_of_users.dat&lt;BR /&gt;&lt;BR /&gt;for help look at man userdel&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Thu, 20 Jan 2005 05:28:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467348#M849151</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2005-01-20T05:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467349#M849152</link>
      <description>Create a file of ids to delete in this format and call it "del":&lt;BR /&gt;&lt;BR /&gt;DEL &lt;ID&gt;&lt;BR /&gt;&lt;BR /&gt;e.g.:&lt;BR /&gt;&lt;BR /&gt;DEL hpdb&lt;BR /&gt;DEL kmo&lt;BR /&gt;&lt;BR /&gt;copy del to a directory&lt;BR /&gt;copy the password file to a directory&lt;BR /&gt;create the following file called cleanit.awk:&lt;BR /&gt;&lt;BR /&gt;BEGIN {FS=":";}&lt;BR /&gt;/^DEL/{FS=" ";&lt;BR /&gt;       countit++;&lt;BR /&gt;       todel[countit]=$2;&lt;BR /&gt;       FS=":";next}&lt;BR /&gt;{daflag=0;&lt;BR /&gt; for (idx1 in todel)&lt;BR /&gt;    if (todel[idx1]==$1) {daflag=1;}&lt;BR /&gt; if (!daflag) {print $0;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;run the following commands:&lt;BR /&gt;cat del passwd &amp;gt; useme&lt;BR /&gt;awk -f cleanit.awk &amp;lt; useme &amp;gt; newfile&lt;BR /&gt;diff passwd newfile&lt;BR /&gt;&lt;BR /&gt;Might not be the prettiest thing around, but it will work.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;BR /&gt;Oz&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/ID&gt;</description>
      <pubDate>Thu, 20 Jan 2005 05:34:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467349#M849152</guid>
      <dc:creator>Kent Ostby</dc:creator>
      <dc:date>2005-01-20T05:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467350#M849153</link>
      <description>Hi Kumar,&lt;BR /&gt;First, make a safe backup copy of /etc/passwd before you do anything else!&lt;BR /&gt;&lt;BR /&gt;Who needs sed or perl? Try something like this:&lt;BR /&gt;&lt;BR /&gt;cp -p /etc/passwd passwd.safe&lt;BR /&gt;cp /etc/passwd passwd.tmp&lt;BR /&gt;for user in `cat deadusers.txt`&lt;BR /&gt;do&lt;BR /&gt;grep -v "^${user}:" passwd.tmp &amp;gt; passwd.tmp2&lt;BR /&gt;mv passwd.tmp2 passwd.tmp&lt;BR /&gt;done&lt;BR /&gt;cp passwd.tmp /etc/passwd&lt;BR /&gt;&lt;BR /&gt;hope that helps</description>
      <pubDate>Thu, 20 Jan 2005 05:35:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467350#M849153</guid>
      <dc:creator>Gordon  Morrison</dc:creator>
      <dc:date>2005-01-20T05:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467351#M849154</link>
      <description>Hi Kumar,&lt;BR /&gt;&lt;BR /&gt;if you put all the IDs to delete to a file then you can use grep to remove them.&lt;BR /&gt;&lt;BR /&gt;Just do something like:&lt;BR /&gt;&lt;BR /&gt;grep -v -f yourfilewithids /etc/passwd &amp;gt; /tmp/newpasswd&lt;BR /&gt;&lt;BR /&gt;Of course doublecheck the result befor you replace the original /etc/passwd&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;&lt;BR /&gt;Regards Stefan</description>
      <pubDate>Thu, 20 Jan 2005 05:40:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467351#M849154</guid>
      <dc:creator>Stefan Schulz</dc:creator>
      <dc:date>2005-01-20T05:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467352#M849155</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;o you have only uid not user names use it:&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;&lt;BR /&gt;if [ -f $1 ]&lt;BR /&gt;then&lt;BR /&gt;        INF=$1&lt;BR /&gt;else&lt;BR /&gt;        exit&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;for ID in `cat ${INF}`&lt;BR /&gt;do&lt;BR /&gt;        UNAME=`cat /etc/passwd | grep ":${ID}:" | awk -F':' '{print $1}'`&lt;BR /&gt;        CMD="userdel -r  ${UNAME}"&lt;BR /&gt;        echo ${CMD}&lt;BR /&gt;        ${CMD}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# $1 - file name of uid-s&lt;BR /&gt;ex:&lt;BR /&gt;106&lt;BR /&gt;107&lt;BR /&gt;108</description>
      <pubDate>Thu, 20 Jan 2005 05:42:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467352#M849155</guid>
      <dc:creator>Slawomir Gora</dc:creator>
      <dc:date>2005-01-20T05:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467353#M849156</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;make a file of users to be deleted&lt;BR /&gt;&lt;BR /&gt;for i in 'cat file'&lt;BR /&gt;do&lt;BR /&gt;userdel -r $i&lt;BR /&gt;done</description>
      <pubDate>Thu, 20 Jan 2005 06:02:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467353#M849156</guid>
      <dc:creator>Ravi_8</dc:creator>
      <dc:date>2005-01-20T06:02:00Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467354#M849157</link>
      <description>&lt;BR /&gt;one more&lt;BR /&gt;&lt;BR /&gt;#cat /etc/passwd |awk -F: '{print $1}' &amp;gt; file&lt;BR /&gt;&lt;BR /&gt;for user in 'cat file'&lt;BR /&gt;do&lt;BR /&gt;echo " Do you want $user to be deleted"&lt;BR /&gt;read x&lt;BR /&gt;if ($x==y)&lt;BR /&gt;userdel -r $user&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Thu, 20 Jan 2005 06:06:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467354#M849157</guid>
      <dc:creator>Ravi_8</dc:creator>
      <dc:date>2005-01-20T06:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467355#M849158</link>
      <description>Thanks Stefan for a short and quick one. Thanks to others for spending time.</description>
      <pubDate>Thu, 20 Jan 2005 17:56:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467355#M849158</guid>
      <dc:creator>Sivasingam Santhakumar</dc:creator>
      <dc:date>2005-01-20T17:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467356#M849159</link>
      <description>An even safer way is to just lock the dead accounts, rather than deleting them:&lt;BR /&gt;&lt;BR /&gt;for user in `cat deadusers.txt`&lt;BR /&gt;do&lt;BR /&gt;passwd -l $user&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;They can then be re-activated later, if necessary, and all of their files will still be there if they're ever needed.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 21 Jan 2005 05:12:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467356#M849159</guid>
      <dc:creator>Gordon  Morrison</dc:creator>
      <dc:date>2005-01-21T05:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467357#M849160</link>
      <description>Kumar,&lt;BR /&gt;also attached a script to identify dormant users i.e. users who have not logged on in the 30 days. May be useful in future&lt;BR /&gt;Regards</description>
      <pubDate>Fri, 21 Jan 2005 05:58:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-question/m-p/3467357#M849160</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2005-01-21T05:58:13Z</dc:date>
    </item>
  </channel>
</rss>

