<?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: Perl Script. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script/m-p/2620215#M925587</link>
    <description>Hi Chris:&lt;BR /&gt;&lt;BR /&gt;The easy way is to make most of what you have eith a subroutine that expect the full pathname as a parameter. Something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;$Dirname = "var/best1/eds_dbc";&lt;BR /&gt;opendir(D1,$Dirname)&lt;BR /&gt;  or die "Opening $Dirname $!\n");&lt;BR /&gt;my @arry1 = grep /\.ant$/, readdir(D1);&lt;BR /&gt;closedir(D1);&lt;BR /&gt;chomp(@arry1);&lt;BR /&gt;my $i = 0;&lt;BR /&gt;while ($i &amp;lt;= $#arry1)&lt;BR /&gt;  {&lt;BR /&gt;    $my fullname = sprintf("%s/%s",$Dirname,$arry1[$i]);&lt;BR /&gt;    printf("Processing %s\n",$fullname);&lt;BR /&gt;#  call your subroutine here&lt;BR /&gt;    ++$i;&lt;BR /&gt;  }&lt;BR /&gt;&lt;BR /&gt;I am assuming that .ant is your desired suffix.&lt;BR /&gt;&lt;BR /&gt;That should do it, Clay</description>
    <pubDate>Mon, 26 Nov 2001 20:44:08 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2001-11-26T20:44:08Z</dc:date>
    <item>
      <title>Perl Script.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script/m-p/2620213#M925585</link>
      <description>Hello to all,&lt;BR /&gt;&lt;BR /&gt;I have a perl script that I have written and the functionality works great, but I would like to add to the functionality, make it more automated.  How do I in perl pars all files in a directory.  Here is the perl script..&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl -w&lt;BR /&gt;###############################################################&lt;BR /&gt;#              summary_parser.pl&lt;BR /&gt;# Description:&lt;BR /&gt;#    This script is intended to parser through a summary report,&lt;BR /&gt;# gathering start, end and interval times, to insure that the,&lt;BR /&gt;# interval time is within the allowable timeframe.  In the event of&lt;BR /&gt;# the interval being not acceptable, or the CPU capture ratio being&lt;BR /&gt;# unacceptable, this script will email the interested parties.&lt;BR /&gt;################################################################&lt;BR /&gt;#################### VARIABLES #################################&lt;BR /&gt;$ACCEPTABLE_INTERVAL=1000;&lt;BR /&gt;$CTR=0;&lt;BR /&gt;#$EMAIL_LIST="me\@me.com";&lt;BR /&gt;$ERROR_MSG="Data is incomplete";&lt;BR /&gt;$SUMMARY="/var/best1/eds_dbc/Oct-14-2001.00.15_eds_dbc.ant";&lt;BR /&gt;$LOWER_CAPTURE=.8;&lt;BR /&gt;$UPPER_CAPTURE=1.8;&lt;BR /&gt;#################### BODY ######################################&lt;BR /&gt;#OPEN THE SUMMARY FILE TO READ FROM.&lt;BR /&gt;open (SUMRY_FILE,"$SUMMARY") ||&lt;BR /&gt;         die "Can't Open $SUMMARY";&lt;BR /&gt;### READ THE LOGFILE INTO AN ARRAY OF WORDS.&lt;BR /&gt;while (&lt;SUMRY_FILE&gt;) {for $chunk(split) {push @ARRAY, $chunk;}}&lt;BR /&gt;### COLLECT THE DATA WE NEED.&lt;BR /&gt;foreach $x (@ARRAY) {&lt;BR /&gt;        if ($x eq "Resulting") {&lt;BR /&gt;                $START_TIME=(substr($ARRAY[$CTR+7], 0,2)*60*60)+(substr($ARRAY[$CTR+7], 3,2)*60)+ (substr($ARRAY[$CTR+7], 6,2));&lt;BR /&gt;        }&lt;BR /&gt;        elsif (($x eq "End")&amp;amp;&amp;amp;($ARRAY[$CTR-1] ne "Collect")) {&lt;BR /&gt;                $END_TIME=(substr($ARRAY[$CTR+5], 0,2)*60*60)+ (substr($ARRAY[$CTR+5], 3,2)*60)+ (substr($ARRAY[$CTR+5], 6,2));&lt;BR /&gt;        }&lt;BR /&gt;          elsif ($x eq "Interval") {&lt;BR /&gt;                $INTERVAL = "$ARRAY[$CTR+3]";&lt;BR /&gt;        }&lt;BR /&gt;        elsif ($x eq "Capture") {&lt;BR /&gt;                $CAPTURE = "$ARRAY[$CTR+2]";&lt;BR /&gt;        }&lt;BR /&gt;        $CTR++;&lt;BR /&gt; }&lt;BR /&gt;### CHECK TO SEE IF THE DATA IS BAD.&lt;BR /&gt;if (($START_TIME+$END_TIME - $INTERVAL &amp;gt; $ACCEPTABLE_INTERVAL) || ($CAPTURE &amp;lt; $LOWER_CAPTURE) || ($CAPTURE &amp;gt; $UPPER_CAPTURE)) {&lt;BR /&gt;        print "\tStart Time: $START_TIME\n+\tEnd Time: $END_TIME\n-\tInterval: $INTERVAL \n=\t\t  ".($START_TIME+$END_TIME - $INTERVAL);&lt;BR /&gt;        print "\n\nCpu Capture Ratio = $CAPTURE\n";&lt;BR /&gt;        print "\nDATA IS INCOMPLETE FOR $SUMMARY!!!\n";&lt;BR /&gt;        ##NOTIFY THE INTERESTED PARTIES.&lt;BR /&gt;        $server = `uname -n`;&lt;BR /&gt;        chomp $server;&lt;BR /&gt;        $stamp=`date +%y/%m/%d`;&lt;BR /&gt;        chomp $stamp;&lt;BR /&gt;        $text = "Data is incomplete";&lt;BR /&gt;        $msg="$server $stamp $ERROR_MSG";&lt;BR /&gt;&lt;BR /&gt;-----------------------------------------------&lt;BR /&gt;Please note the $SUMMARY variable, I am having problems trying pars all files in a directory.  I am stumped.&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;&lt;BR /&gt;ct&lt;/SUMRY_FILE&gt;</description>
      <pubDate>Mon, 26 Nov 2001 19:55:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script/m-p/2620213#M925585</guid>
      <dc:creator>Chris Tijerina_2</dc:creator>
      <dc:date>2001-11-26T19:55:37Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Script.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script/m-p/2620214#M925586</link>
      <description>opendir(MYDIR,"/path/path/")&lt;BR /&gt;while($file=readdir(MYDIR)) {&lt;BR /&gt; open(INP," while(&lt;INP&gt;) {&lt;BR /&gt;  .. process file ..&lt;BR /&gt; }&lt;BR /&gt;}&lt;/INP&gt;</description>
      <pubDate>Mon, 26 Nov 2001 20:19:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script/m-p/2620214#M925586</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2001-11-26T20:19:43Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Script.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script/m-p/2620215#M925587</link>
      <description>Hi Chris:&lt;BR /&gt;&lt;BR /&gt;The easy way is to make most of what you have eith a subroutine that expect the full pathname as a parameter. Something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;$Dirname = "var/best1/eds_dbc";&lt;BR /&gt;opendir(D1,$Dirname)&lt;BR /&gt;  or die "Opening $Dirname $!\n");&lt;BR /&gt;my @arry1 = grep /\.ant$/, readdir(D1);&lt;BR /&gt;closedir(D1);&lt;BR /&gt;chomp(@arry1);&lt;BR /&gt;my $i = 0;&lt;BR /&gt;while ($i &amp;lt;= $#arry1)&lt;BR /&gt;  {&lt;BR /&gt;    $my fullname = sprintf("%s/%s",$Dirname,$arry1[$i]);&lt;BR /&gt;    printf("Processing %s\n",$fullname);&lt;BR /&gt;#  call your subroutine here&lt;BR /&gt;    ++$i;&lt;BR /&gt;  }&lt;BR /&gt;&lt;BR /&gt;I am assuming that .ant is your desired suffix.&lt;BR /&gt;&lt;BR /&gt;That should do it, Clay</description>
      <pubDate>Mon, 26 Nov 2001 20:44:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script/m-p/2620215#M925587</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2001-11-26T20:44:08Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Script.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script/m-p/2620216#M925588</link>
      <description>Hi again. My advanced typing techniques bit me again. This should be the die line:&lt;BR /&gt;&lt;BR /&gt;or die "Opening $Dirname $!\n"; &lt;BR /&gt;&lt;BR /&gt;Clay&lt;BR /&gt;</description>
      <pubDate>Mon, 26 Nov 2001 20:48:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script/m-p/2620216#M925588</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2001-11-26T20:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Script.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script/m-p/2620217#M925589</link>
      <description>Clay,&lt;BR /&gt;&lt;BR /&gt;what do you mean by:&lt;BR /&gt;&lt;BR /&gt;printf("Processing %s\n",$fullname); &lt;BR /&gt;# call your subroutine here &lt;BR /&gt;++$i; &lt;BR /&gt;} &lt;BR /&gt;&lt;BR /&gt;"call your subroutine here"??&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;ct</description>
      <pubDate>Mon, 26 Nov 2001 22:06:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script/m-p/2620217#M925589</guid>
      <dc:creator>Chris Tijerina_2</dc:creator>
      <dc:date>2001-11-26T22:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Script.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script/m-p/2620218#M925590</link>
      <description>Hi Chris:&lt;BR /&gt;&lt;BR /&gt;What I meant was that I wanted for you to turn all of your existing script into a perl sub that expects 1 argument - the full pathname to the file that you wish to parse.&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;sub myparser&lt;BR /&gt;{&lt;BR /&gt;  my $SUMMERY = $_[0];&lt;BR /&gt;  ...&lt;BR /&gt;  ...&lt;BR /&gt;  ...&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;You would then call it in the while loop like:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;myparser($fullname);&lt;BR /&gt;&lt;BR /&gt;Plan B.&lt;BR /&gt;&lt;BR /&gt;Modify your existing script to parse the command line to get the fullname as the first arg. You then call that perl script from within the perl script containing the loop.&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;my $cmd = sprintf("perl myscript.pl %s",$fullname);&lt;BR /&gt;system($cmd);&lt;BR /&gt;&lt;BR /&gt;Plan B is much less efficient!&lt;BR /&gt;&lt;BR /&gt;Regards, Clay&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 26 Nov 2001 22:54:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script/m-p/2620218#M925590</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2001-11-26T22:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: Perl Script.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script/m-p/2620219#M925591</link>
      <description>You are too cool!  Thanks a million.&lt;BR /&gt;&lt;BR /&gt;If I could assign a million points to you, I would!&lt;BR /&gt;&lt;BR /&gt;ct</description>
      <pubDate>Mon, 26 Nov 2001 23:04:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script/m-p/2620219#M925591</guid>
      <dc:creator>Chris Tijerina_2</dc:creator>
      <dc:date>2001-11-26T23:04:25Z</dc:date>
    </item>
  </channel>
</rss>

