<?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 PERL help needed in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-help-needed/m-p/2882475#M101262</link>
    <description>HI,&lt;BR /&gt;&lt;BR /&gt;I have a PERL script below which checks for the existence of filenames having the string "spool" as their prefixes and tokenizes the contents of those "spool" files. Purpose of this script is write the necessary  information from the "spool" into a log file to indicate users which have been added/removed from a group by respective owner. &lt;BR /&gt;&lt;BR /&gt;Contents of the "spool" as as follows, separated by colons:&lt;BR /&gt;remove:ken_lee:groupA:joe_wong:ken_lee&lt;BR /&gt;add:ken_lee:groupA:alice:ken_lee&lt;BR /&gt;&lt;BR /&gt;field 1: action add/remove to indicate a user is to be added or remove from a NIS /var/yp/src/group file&lt;BR /&gt;&lt;BR /&gt;field 2: group owner i.e ken_lee&lt;BR /&gt;field 3:name of group i.e groupA&lt;BR /&gt;field 4: name of user to be added/removed from NIS master group file i.e alice or joe_wong&lt;BR /&gt;&lt;BR /&gt;field 5: group owner again&lt;BR /&gt;&lt;BR /&gt;The script would need to have the group name, group owner and user to be added/remove and the action field from the "spool" file to be written into a log file. The log file would need to be in the format of:&lt;BR /&gt;groupname  owner  user  date   action&lt;BR /&gt;--------------------------------------&lt;BR /&gt;groupA     ken_lee alice Jan10 add&lt;BR /&gt;&lt;BR /&gt;Names of the log file should be have the following form:&lt;BR /&gt;year-month-groupname&lt;BR /&gt;e.g. 2003-Jan-groupA&lt;BR /&gt;The date field in the log file would be based on date of the "spool" file obtained by doing a "ls -l spool*". &lt;BR /&gt;&lt;BR /&gt;However in my script, I tried creating a file of the form year-month-groupname to be able to write the groupname, owner, user, date, action into it, and the script produced the error attached in this message. &lt;BR /&gt;&lt;BR /&gt;Could someone kindly tell me how I should fix the error in the attachment?&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;@spoolList = `ls -l /tmp/spool* |grep -v total`;&lt;BR /&gt;&lt;BR /&gt;foreach $i (@spoolList){&lt;BR /&gt;   @splitSpoolList = split(/\s+/, $i);&lt;BR /&gt;   $spoolFile = $splitSpoolList[8];&lt;BR /&gt;   $day = $splitSpoolList[6];&lt;BR /&gt;   $time = $splitSpoolList[7];&lt;BR /&gt;   $month = $splitSpoolList[5];&lt;BR /&gt;   &amp;amp;processSpoolFileList($spoolFile);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;sub processSpoolFile{&lt;BR /&gt;       $fileName = shift(@_);&lt;BR /&gt;        @spoolFileTokens = split(/:/,`cat $fileName`);&lt;BR /&gt;        #foreach $k (@spoolFileTokens){&lt;BR /&gt;        #        print "$k \n";&lt;BR /&gt;        #}&lt;BR /&gt; $action = $spoolFileTokens[0];&lt;BR /&gt; $owner = $spoolFileTokens[1];&lt;BR /&gt; $grpName = $spoolFileTokens[2];&lt;BR /&gt; $user = $spoolFileTokens[3];&lt;BR /&gt; #for($a=0; $a &amp;lt; @spoolFileTokens; $a++){&lt;BR /&gt; # print "\$spoolFileTokens[$a] = $spoolFileTokens[$a]&lt;BR /&gt;\n";&lt;BR /&gt; #}&lt;BR /&gt;        &amp;amp;writeToLog($action, $owner, $grpName, $user, $day, $time,&lt;BR /&gt;$month);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;sub writeToLog{&lt;BR /&gt; local($action, $owner, $grpName, $user, $day, $time,&lt;BR /&gt;$month) = @_;&lt;BR /&gt;        &lt;BR /&gt; $year = &amp;amp;getYear;&lt;BR /&gt; print "$year \n";&lt;BR /&gt; $logFile = $year"-"$month"-"$grpName;&lt;BR /&gt; print "\$logFile = $logFile \n";&lt;BR /&gt;        open(file, "&amp;gt;&amp;gt;/home/$logFile") || die "open $logFile for append \n";&lt;BR /&gt;         print file "group\t owner\t user\t date\t action \n"; &lt;BR /&gt;print&lt;BR /&gt;file "$grpName\t$owner\t$user\t$date\t$action\n";&lt;BR /&gt;         close file; &lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;sub getYear{&lt;BR /&gt;        $tmpDate = `date`;&lt;BR /&gt;  print "$tmpDate \n";   &lt;BR /&gt;        @dateStuff = split(/\s+/,$tmpDate);&lt;BR /&gt;        $year = $dateStuff[5];&lt;BR /&gt;        print "\$year = $year \n";&lt;BR /&gt; return $year;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Also, how do I write the contents of the log file with the headers as specified below? :&lt;BR /&gt;groupname  owner  user  date   action&lt;BR /&gt;--------------------------------------&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Could anyone kindly help me out?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt; &lt;BR /&gt;</description>
    <pubDate>Wed, 15 Jan 2003 12:03:47 GMT</pubDate>
    <dc:creator>Chern Jian Leaw</dc:creator>
    <dc:date>2003-01-15T12:03:47Z</dc:date>
    <item>
      <title>PERL help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-help-needed/m-p/2882475#M101262</link>
      <description>HI,&lt;BR /&gt;&lt;BR /&gt;I have a PERL script below which checks for the existence of filenames having the string "spool" as their prefixes and tokenizes the contents of those "spool" files. Purpose of this script is write the necessary  information from the "spool" into a log file to indicate users which have been added/removed from a group by respective owner. &lt;BR /&gt;&lt;BR /&gt;Contents of the "spool" as as follows, separated by colons:&lt;BR /&gt;remove:ken_lee:groupA:joe_wong:ken_lee&lt;BR /&gt;add:ken_lee:groupA:alice:ken_lee&lt;BR /&gt;&lt;BR /&gt;field 1: action add/remove to indicate a user is to be added or remove from a NIS /var/yp/src/group file&lt;BR /&gt;&lt;BR /&gt;field 2: group owner i.e ken_lee&lt;BR /&gt;field 3:name of group i.e groupA&lt;BR /&gt;field 4: name of user to be added/removed from NIS master group file i.e alice or joe_wong&lt;BR /&gt;&lt;BR /&gt;field 5: group owner again&lt;BR /&gt;&lt;BR /&gt;The script would need to have the group name, group owner and user to be added/remove and the action field from the "spool" file to be written into a log file. The log file would need to be in the format of:&lt;BR /&gt;groupname  owner  user  date   action&lt;BR /&gt;--------------------------------------&lt;BR /&gt;groupA     ken_lee alice Jan10 add&lt;BR /&gt;&lt;BR /&gt;Names of the log file should be have the following form:&lt;BR /&gt;year-month-groupname&lt;BR /&gt;e.g. 2003-Jan-groupA&lt;BR /&gt;The date field in the log file would be based on date of the "spool" file obtained by doing a "ls -l spool*". &lt;BR /&gt;&lt;BR /&gt;However in my script, I tried creating a file of the form year-month-groupname to be able to write the groupname, owner, user, date, action into it, and the script produced the error attached in this message. &lt;BR /&gt;&lt;BR /&gt;Could someone kindly tell me how I should fix the error in the attachment?&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;@spoolList = `ls -l /tmp/spool* |grep -v total`;&lt;BR /&gt;&lt;BR /&gt;foreach $i (@spoolList){&lt;BR /&gt;   @splitSpoolList = split(/\s+/, $i);&lt;BR /&gt;   $spoolFile = $splitSpoolList[8];&lt;BR /&gt;   $day = $splitSpoolList[6];&lt;BR /&gt;   $time = $splitSpoolList[7];&lt;BR /&gt;   $month = $splitSpoolList[5];&lt;BR /&gt;   &amp;amp;processSpoolFileList($spoolFile);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;sub processSpoolFile{&lt;BR /&gt;       $fileName = shift(@_);&lt;BR /&gt;        @spoolFileTokens = split(/:/,`cat $fileName`);&lt;BR /&gt;        #foreach $k (@spoolFileTokens){&lt;BR /&gt;        #        print "$k \n";&lt;BR /&gt;        #}&lt;BR /&gt; $action = $spoolFileTokens[0];&lt;BR /&gt; $owner = $spoolFileTokens[1];&lt;BR /&gt; $grpName = $spoolFileTokens[2];&lt;BR /&gt; $user = $spoolFileTokens[3];&lt;BR /&gt; #for($a=0; $a &amp;lt; @spoolFileTokens; $a++){&lt;BR /&gt; # print "\$spoolFileTokens[$a] = $spoolFileTokens[$a]&lt;BR /&gt;\n";&lt;BR /&gt; #}&lt;BR /&gt;        &amp;amp;writeToLog($action, $owner, $grpName, $user, $day, $time,&lt;BR /&gt;$month);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;sub writeToLog{&lt;BR /&gt; local($action, $owner, $grpName, $user, $day, $time,&lt;BR /&gt;$month) = @_;&lt;BR /&gt;        &lt;BR /&gt; $year = &amp;amp;getYear;&lt;BR /&gt; print "$year \n";&lt;BR /&gt; $logFile = $year"-"$month"-"$grpName;&lt;BR /&gt; print "\$logFile = $logFile \n";&lt;BR /&gt;        open(file, "&amp;gt;&amp;gt;/home/$logFile") || die "open $logFile for append \n";&lt;BR /&gt;         print file "group\t owner\t user\t date\t action \n"; &lt;BR /&gt;print&lt;BR /&gt;file "$grpName\t$owner\t$user\t$date\t$action\n";&lt;BR /&gt;         close file; &lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;sub getYear{&lt;BR /&gt;        $tmpDate = `date`;&lt;BR /&gt;  print "$tmpDate \n";   &lt;BR /&gt;        @dateStuff = split(/\s+/,$tmpDate);&lt;BR /&gt;        $year = $dateStuff[5];&lt;BR /&gt;        print "\$year = $year \n";&lt;BR /&gt; return $year;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Also, how do I write the contents of the log file with the headers as specified below? :&lt;BR /&gt;groupname  owner  user  date   action&lt;BR /&gt;--------------------------------------&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Could anyone kindly help me out?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt; &lt;BR /&gt;</description>
      <pubDate>Wed, 15 Jan 2003 12:03:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-help-needed/m-p/2882475#M101262</guid>
      <dc:creator>Chern Jian Leaw</dc:creator>
      <dc:date>2003-01-15T12:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: PERL help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-help-needed/m-p/2882476#M101263</link>
      <description>&lt;BR /&gt;Line 41 and line 42 need to be concatenated:&lt;BR /&gt;&lt;BR /&gt;print file "$grpName\t$owner\t$user\t$date\t$action\n";&lt;BR /&gt;&lt;BR /&gt;Line 25, the \n"; needs to be wither appended to the above print statement or commented out&lt;BR /&gt;&lt;BR /&gt;Line 37, change to this:&lt;BR /&gt;$logFile = $year."-".$month."-".$grpName;&lt;BR /&gt;&lt;BR /&gt;Periods are string concat operators.&lt;BR /&gt;&lt;BR /&gt;Line 13, the subroutine is called processSpoolFile, but you call it on line 10 as processSpoolFileList. So either change the subroutine name from processSpoolFile to processSpoolFileList, or change line 10 to reflect the name of processSpoolFile.&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 15 Jan 2003 12:47:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-help-needed/m-p/2882476#M101263</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2003-01-15T12:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: PERL help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-help-needed/m-p/2882477#M101264</link>
      <description>&lt;BR /&gt;I attached the changes, but you need to REPLACE the first line from /opt/perl/bin/perl to your /usr/bin/perl.&lt;BR /&gt;&lt;BR /&gt;have fun&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Wed, 15 Jan 2003 12:51:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-help-needed/m-p/2882477#M101264</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2003-01-15T12:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: PERL help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-help-needed/m-p/2882478#M101265</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;If I seen it right you have the \n on a new line. Don't know if this is messed up by cut and past, but this might be your problem. &lt;BR /&gt;If you want answers on Perl questions, please look at the site : &lt;A href="http://learn.perl.org/" target="_blank"&gt;http://learn.perl.org/&lt;/A&gt;&lt;BR /&gt;You can subscribe yourself to a mailinglist, and I can garantuee your problem will be solved in minutes.&lt;BR /&gt;&lt;BR /&gt;# print "\$spoolFileTokens[$a] = $spoolFileTokens[$a] &lt;BR /&gt;\n"; &lt;BR /&gt;&lt;BR /&gt;Best Regs David&lt;BR /&gt;</description>
      <pubDate>Wed, 15 Jan 2003 12:58:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-help-needed/m-p/2882478#M101265</guid>
      <dc:creator>David_246</dc:creator>
      <dc:date>2003-01-15T12:58:39Z</dc:date>
    </item>
  </channel>
</rss>

