<?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: Disk Usage/Auditing and e-mail in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-usage-auditing-and-e-mail/m-p/2461114#M14130</link>
    <description>OK, Try this statement.&lt;BR /&gt;&lt;BR /&gt;owner_email=`grep $owner  /etc/passwd | awk -F: '{print $5}' | awk '{print $1"_"$2"@ham.honda.com"}'`&lt;BR /&gt;&lt;BR /&gt;This statement is taking the value of the $owner variable that was set in the script in my last reply and this takes the place of owner2.  This is also assuming that the users real name in the /etc/passwd file (5th field) is in the form of 'first_name last_name' with no punctuation in there.  If the first name and last name are reversed just do a $2"_"$1 in the above statement.&lt;BR /&gt;&lt;BR /&gt;I believe that this will give you what you want.  It may not be as elegant as some of the other scripting gurus out there can do, but it should work for you.  It may be possible to combine the two statements, I haven't played with that.  I may do that while I'm at the office tomorrow.  I'll post results here if I succeed.</description>
    <pubDate>Fri, 03 Nov 2000 05:51:41 GMT</pubDate>
    <dc:creator>Patrick Wallek</dc:creator>
    <dc:date>2000-11-03T05:51:41Z</dc:date>
    <item>
      <title>Disk Usage/Auditing and e-mail</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-usage-auditing-and-e-mail/m-p/2461111#M14127</link>
      <description>I am attempting to write a little script to get the disk usage from every user's home directory and send them a report.  Currently the script is sound as far as getting the proper data.  I haven't been able to figure out how to manipulate any files/commands to extract the username according to the specific users directory.  Any suggestions would be great.  Here is what I have for a script, where "users.dir" is a file of user directories in /home.&lt;BR /&gt;&lt;BR /&gt;for i in `cat users.dir`&lt;BR /&gt;do&lt;BR /&gt;cd /home&lt;BR /&gt;du -k $i | mailx -s "Weekly Disk Usage for servername" [e-mail address]&lt;BR /&gt;done</description>
      <pubDate>Thu, 02 Nov 2000 22:28:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-usage-auditing-and-e-mail/m-p/2461111#M14127</guid>
      <dc:creator>randy lee</dc:creator>
      <dc:date>2000-11-02T22:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: Disk Usage/Auditing and e-mail</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-usage-auditing-and-e-mail/m-p/2461112#M14128</link>
      <description>You could try something similar to this to get the owner of the home directory:&lt;BR /&gt;&lt;BR /&gt;owner=`ll -d /home/$i | awk ' {print $3} '`&lt;BR /&gt;&lt;BR /&gt;If you need the real name of the person, if it is in your passwd file you could do this then:&lt;BR /&gt;&lt;BR /&gt;owner2=`grep $owner /etc/passwd | awk -F: ' {print $5}'`&lt;BR /&gt;&lt;BR /&gt;You could probably combine the two statements into one if you like.&lt;BR /&gt;&lt;BR /&gt;Hope this helps.</description>
      <pubDate>Thu, 02 Nov 2000 22:36:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-usage-auditing-and-e-mail/m-p/2461112#M14128</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2000-11-02T22:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Disk Usage/Auditing and e-mail</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-usage-auditing-and-e-mail/m-p/2461113#M14129</link>
      <description>Yes, I want to extract the real user's name, so that I can format it to our e-mail format first_last@ham.honda.com.</description>
      <pubDate>Thu, 02 Nov 2000 22:39:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-usage-auditing-and-e-mail/m-p/2461113#M14129</guid>
      <dc:creator>randy lee</dc:creator>
      <dc:date>2000-11-02T22:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: Disk Usage/Auditing and e-mail</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-usage-auditing-and-e-mail/m-p/2461114#M14130</link>
      <description>OK, Try this statement.&lt;BR /&gt;&lt;BR /&gt;owner_email=`grep $owner  /etc/passwd | awk -F: '{print $5}' | awk '{print $1"_"$2"@ham.honda.com"}'`&lt;BR /&gt;&lt;BR /&gt;This statement is taking the value of the $owner variable that was set in the script in my last reply and this takes the place of owner2.  This is also assuming that the users real name in the /etc/passwd file (5th field) is in the form of 'first_name last_name' with no punctuation in there.  If the first name and last name are reversed just do a $2"_"$1 in the above statement.&lt;BR /&gt;&lt;BR /&gt;I believe that this will give you what you want.  It may not be as elegant as some of the other scripting gurus out there can do, but it should work for you.  It may be possible to combine the two statements, I haven't played with that.  I may do that while I'm at the office tomorrow.  I'll post results here if I succeed.</description>
      <pubDate>Fri, 03 Nov 2000 05:51:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-usage-auditing-and-e-mail/m-p/2461114#M14130</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2000-11-03T05:51:41Z</dc:date>
    </item>
    <item>
      <title>Re: Disk Usage/Auditing and e-mail</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-usage-auditing-and-e-mail/m-p/2461115#M14131</link>
      <description>just a slight "improvement" to Patrick's suggestion.&lt;BR /&gt;Why bothering grep while awk can do the job alone?&lt;BR /&gt;&lt;BR /&gt;awk -v pwnam=$owner -F: '$1==pwnam {print $5}' /etc/passwd&lt;BR /&gt;&lt;BR /&gt;If you want to be kind of portable don't rely on awk's -v flag though.&lt;BR /&gt;Not all awk versions support this flag.&lt;BR /&gt;Instead you would rather pass it the shell's variable owner as extra argument.&lt;BR /&gt;But with HP's awk it should work.&lt;BR /&gt;&lt;BR /&gt;If you're keen on using Perl you could do something like this:&lt;BR /&gt;&lt;BR /&gt;perl -e 'while (($user,$gcos)=(getpwent())[0,5]) {print "$gcosn" if ($user eq $ARGV[0])}' $owner&lt;BR /&gt;&lt;BR /&gt;For details see POD&lt;BR /&gt;perldoc -f getpwent&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 03 Nov 2000 07:52:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-usage-auditing-and-e-mail/m-p/2461115#M14131</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2000-11-03T07:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: Disk Usage/Auditing and e-mail</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-usage-auditing-and-e-mail/m-p/2461116#M14132</link>
      <description>Aargh...&lt;BR /&gt;I always forget to extra quote backslashes in this forum!&lt;BR /&gt;&lt;BR /&gt;Of course, in the Perl line it has to read&lt;BR /&gt;&lt;BR /&gt;... print "$gcos\n" ...&lt;BR /&gt;</description>
      <pubDate>Fri, 03 Nov 2000 07:59:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-usage-auditing-and-e-mail/m-p/2461116#M14132</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2000-11-03T07:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: Disk Usage/Auditing and e-mail</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-usage-auditing-and-e-mail/m-p/2461117#M14133</link>
      <description>Sorry, looping through each passwd entry isn't really perlish.&lt;BR /&gt;This seems more appropriate:&lt;BR /&gt;&lt;BR /&gt;perl -e 'print "@{[(getpwnam($ARGV[0]))[5]]}\n"' $owner&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 03 Nov 2000 09:19:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-usage-auditing-and-e-mail/m-p/2461117#M14133</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2000-11-03T09:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: Disk Usage/Auditing and e-mail</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-usage-auditing-and-e-mail/m-p/2461118#M14134</link>
      <description>within your script $i already points to the user name, so you can do&lt;BR /&gt;mail_user=$(pwget -n $i |awk -F: '{print $5}')@ham.honda.com&lt;BR /&gt;</description>
      <pubDate>Fri, 03 Nov 2000 09:32:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-usage-auditing-and-e-mail/m-p/2461118#M14134</guid>
      <dc:creator>Rainer_1</dc:creator>
      <dc:date>2000-11-03T09:32:00Z</dc:date>
    </item>
    <item>
      <title>Re: Disk Usage/Auditing and e-mail</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/disk-usage-auditing-and-e-mail/m-p/2461119#M14135</link>
      <description>Randy,&lt;BR /&gt;&lt;BR /&gt;Here's a complete script that should work for you.  This includes some of Ralph's suggestions, so be sure to assign points to him too.  &lt;BR /&gt;&lt;BR /&gt;Rainer's suggestion will only work if the home directory name is the same as the user name, which is not always the case.&lt;BR /&gt;&lt;BR /&gt;Here is the complete script:&lt;BR /&gt;&lt;BR /&gt;for i in `cat users.dir`&lt;BR /&gt;&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;cd /home&lt;BR /&gt;&lt;BR /&gt;owner=`ll -d /home/$i | awk '{print $3}'` &lt;BR /&gt;&lt;BR /&gt;email=`awk -v pwnam=$owner -F: '$1==pwnam {print $5}' /etc/passwd | awk '{print $1"_"$2"@ham.honda.com"}'`&lt;BR /&gt;&lt;BR /&gt;du -k $i | mailx -s "Weekly Disk Usage for `uname -n`" $email&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Hope this is what you need.</description>
      <pubDate>Fri, 03 Nov 2000 15:32:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/disk-usage-auditing-and-e-mail/m-p/2461119#M14135</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2000-11-03T15:32:41Z</dc:date>
    </item>
  </channel>
</rss>

