<?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: shell to perl script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-to-perl-script/m-p/4712670#M659945</link>
    <description>great, thanks a ton...i will check them... i will provide one opcragt output as well...&lt;BR /&gt;&lt;BR /&gt;one more small grep help...i am having two list of nodes. i want to compare them and make the list of nodes present in fair and missing in app1&lt;BR /&gt;ie, &lt;BR /&gt;grep $NODE app1-node-list &amp;gt;&amp;gt;present&lt;BR /&gt;if $NODE not present in app1 node list, i want to write it in a new file...how to do that please....&lt;BR /&gt;&lt;BR /&gt;root@fair&amp;gt; ll&lt;BR /&gt;total 224&lt;BR /&gt;-rw-r--r--   1 root       sys          85757 Nov 12 01:47 app1-node-list&lt;BR /&gt;-rw-r--r--   1 root       sys          19198 Nov 12 08:25 fair-node-list&lt;BR /&gt;root@fair&amp;gt;&lt;BR /&gt;root@fair&amp;gt; for NODE in `cat fair-node-list`&lt;BR /&gt;&amp;gt; do&lt;BR /&gt;&amp;gt; grep $NODE app1-node-list &amp;gt;&amp;gt;present&lt;BR /&gt;&amp;gt; done&lt;BR /&gt;root@fair&amp;gt; ll&lt;BR /&gt;total 256&lt;BR /&gt;-rw-r--r--   1 root       sys          85757 Nov 12 01:47 app1-node-list&lt;BR /&gt;-rw-r--r--   1 root       sys          19198 Nov 12 08:25 fair-node-list&lt;BR /&gt;-rw-r--r--   1 root       sys          14017 Nov 12 09:28 present&lt;BR /&gt;root@fair&amp;gt; wc *&lt;BR /&gt;7637 7660 85757 app1-node-list&lt;BR /&gt;1576 1570 19198 fair-node-list&lt;BR /&gt;1192 1192 14017 present&lt;BR /&gt;10405 10422 118972 total&lt;BR /&gt;root@fair&amp;gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 12 Nov 2010 14:59:23 GMT</pubDate>
    <dc:creator>sekar sundaram</dc:creator>
    <dc:date>2010-11-12T14:59:23Z</dc:date>
    <item>
      <title>shell to perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-to-perl-script/m-p/4712667#M659942</link>
      <description>hi, &lt;BR /&gt;i would like to convert a small shell script to perl.&lt;BR /&gt;-------&lt;BR /&gt;for NODE in `cat node-list.txt`&lt;BR /&gt;do&lt;BR /&gt;#run this commnad opcragt $NODE &lt;BR /&gt;#and check the output is like this&lt;BR /&gt;#Node specified with Primary Node Name is not managed by HPOM for Windows&lt;BR /&gt;#write that node name into a file&lt;BR /&gt;if [ opcragt $NODE | grep HPOM ]&lt;BR /&gt; echo $NODE &amp;gt;&amp;gt; node-not-available.txt&lt;BR /&gt;#if yes, mean, node is not managed&lt;BR /&gt;----------&lt;BR /&gt;&lt;BR /&gt;thanks...&lt;BR /&gt;</description>
      <pubDate>Fri, 12 Nov 2010 12:40:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-to-perl-script/m-p/4712667#M659942</guid>
      <dc:creator>sekar sundaram</dc:creator>
      <dc:date>2010-11-12T12:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: shell to perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-to-perl-script/m-p/4712668#M659943</link>
      <description>&lt;!--!*#--&gt;1) I do not have 'opcragt' available so I don't know exactly what the output would look like.&lt;BR /&gt;Provide a good/bad example for better help.&lt;BR /&gt;&lt;BR /&gt;2) You may want to use the -all option and parse the output against a pre-read node list.&lt;BR /&gt;&lt;BR /&gt;Check out: &lt;A href="http://perlmeme.org/faqs/system/system.html" target="_blank"&gt;http://perlmeme.org/faqs/system/system.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Anyway... 1) could be done using something like:&lt;BR /&gt;&lt;BR /&gt;# perl x.pl &amp;lt; node-list.txt &amp;gt;&amp;gt; node-not-available.txt&lt;BR /&gt;where (untested) ...&lt;BR /&gt;-- x.pl --&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;while (my $node = &amp;lt;&amp;gt;) {&lt;BR /&gt;   chomp $node;&lt;BR /&gt;   for (qx(opcragt $node)) {&lt;BR /&gt;       if (/HPOM/) {&lt;BR /&gt;           print qq($node\n);&lt;BR /&gt;           last;&lt;BR /&gt;        }&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Hope this help some,&lt;BR /&gt;Hein&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 12 Nov 2010 13:36:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-to-perl-script/m-p/4712668#M659943</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2010-11-12T13:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: shell to perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-to-perl-script/m-p/4712669#M659944</link>
      <description>&lt;!--!*#--&gt;Hi:&lt;BR /&gt;&lt;BR /&gt;You haven't provided a shell script other than in pseudocode.  Using 'echo' instead of 'opcragt' to demonstrate, if you had something like:&lt;BR /&gt;&lt;BR /&gt;# cat ./mysh&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;for NODE in $(&amp;lt; node-list.txt)&lt;BR /&gt;do&lt;BR /&gt;    if [ $(echo $NODE | grep -s HPOM) ]; then&lt;BR /&gt;        echo "${NODE} not managed"&lt;BR /&gt;    else&lt;BR /&gt;        echo "${NODE} managed"&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;...in Perl, we could do:&lt;BR /&gt;&lt;BR /&gt;# cat ./mypl&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my $result;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;    chomp;&lt;BR /&gt;    $result = `echo $_ | grep -s HPOM`;&lt;BR /&gt;    if ( $result =~ /HPOM/ ) { &lt;BR /&gt;        print "$_ not managed\n"&lt;BR /&gt;    }&lt;BR /&gt;    else {&lt;BR /&gt;        print "$_ managed\n"&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;1;&lt;BR /&gt;&lt;BR /&gt;...which given an input file named 'node-list.txt' would  be run like:&lt;BR /&gt;&lt;BR /&gt;# ./mysh&lt;BR /&gt;&lt;BR /&gt;(or):&lt;BR /&gt;&lt;BR /&gt;# ./mypl node-lst-txt&lt;BR /&gt;&lt;BR /&gt;If the contents of the input looked like:&lt;BR /&gt;&lt;BR /&gt;# cat node-list.txt&lt;BR /&gt;node_one&lt;BR /&gt;node_two&lt;BR /&gt;node_HPOM&lt;BR /&gt;node_three&lt;BR /&gt;&lt;BR /&gt;...then the output of either the shell or the Perl script would be:&lt;BR /&gt;&lt;BR /&gt;node_one managed&lt;BR /&gt;node_two managed&lt;BR /&gt;node_HPOM not managed&lt;BR /&gt;node_three managed&lt;BR /&gt;&lt;BR /&gt;You can redirect the output when you run either variation.  I prefer to do this rather than embed that logic.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Fri, 12 Nov 2010 13:47:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-to-perl-script/m-p/4712669#M659944</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-11-12T13:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: shell to perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-to-perl-script/m-p/4712670#M659945</link>
      <description>great, thanks a ton...i will check them... i will provide one opcragt output as well...&lt;BR /&gt;&lt;BR /&gt;one more small grep help...i am having two list of nodes. i want to compare them and make the list of nodes present in fair and missing in app1&lt;BR /&gt;ie, &lt;BR /&gt;grep $NODE app1-node-list &amp;gt;&amp;gt;present&lt;BR /&gt;if $NODE not present in app1 node list, i want to write it in a new file...how to do that please....&lt;BR /&gt;&lt;BR /&gt;root@fair&amp;gt; ll&lt;BR /&gt;total 224&lt;BR /&gt;-rw-r--r--   1 root       sys          85757 Nov 12 01:47 app1-node-list&lt;BR /&gt;-rw-r--r--   1 root       sys          19198 Nov 12 08:25 fair-node-list&lt;BR /&gt;root@fair&amp;gt;&lt;BR /&gt;root@fair&amp;gt; for NODE in `cat fair-node-list`&lt;BR /&gt;&amp;gt; do&lt;BR /&gt;&amp;gt; grep $NODE app1-node-list &amp;gt;&amp;gt;present&lt;BR /&gt;&amp;gt; done&lt;BR /&gt;root@fair&amp;gt; ll&lt;BR /&gt;total 256&lt;BR /&gt;-rw-r--r--   1 root       sys          85757 Nov 12 01:47 app1-node-list&lt;BR /&gt;-rw-r--r--   1 root       sys          19198 Nov 12 08:25 fair-node-list&lt;BR /&gt;-rw-r--r--   1 root       sys          14017 Nov 12 09:28 present&lt;BR /&gt;root@fair&amp;gt; wc *&lt;BR /&gt;7637 7660 85757 app1-node-list&lt;BR /&gt;1576 1570 19198 fair-node-list&lt;BR /&gt;1192 1192 14017 present&lt;BR /&gt;10405 10422 118972 total&lt;BR /&gt;root@fair&amp;gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 12 Nov 2010 14:59:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-to-perl-script/m-p/4712670#M659945</guid>
      <dc:creator>sekar sundaram</dc:creator>
      <dc:date>2010-11-12T14:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: shell to perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-to-perl-script/m-p/4712671#M659946</link>
      <description>&lt;!--!*#--&gt;&lt;BR /&gt;well, you could just use : &lt;BR /&gt;&lt;BR /&gt;   grep -f app1-node-list fair-node-list&lt;BR /&gt;&lt;BR /&gt;Beware that the lines in the first file mentioned are treated as regular expression PATTERNs. Do depending on needs, feeds and platform you may want to add any or all of:&lt;BR /&gt;  -i, ignore case distinctions&lt;BR /&gt;  -w, force PATTERN to match only whole words&lt;BR /&gt;  -x, force PATTERN to match only whole lines&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;If you need more work to be done, then the following working, rough, framework may help:&lt;BR /&gt;&lt;BR /&gt;perl present.pl app1-node-list fair-node-list&lt;BR /&gt;&lt;BR /&gt;where&lt;BR /&gt;----------------- present.pl -------&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my %first;&lt;BR /&gt;&lt;BR /&gt;my $input_file = shift or die "Need a first file to work on";&lt;BR /&gt;open (FILE, "&amp;lt;$input_file") or die "Could not open first file $input_file\n$!";&lt;BR /&gt;$first{$_}=1 for (&lt;FILE&gt;);&lt;BR /&gt;print scalar keys %first, " lines in first $input_file\nPresent:\n";&lt;BR /&gt;&lt;BR /&gt;$input_file = shift or die "Need a second file to work on";&lt;BR /&gt;open (FILE, "&amp;lt;$input_file") or die "Could not open second file $input_file\n$!";&lt;BR /&gt;for (&lt;FILE&gt;) {&lt;BR /&gt;  print if $first{$_};&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Enjoy,&lt;BR /&gt;Hein&lt;BR /&gt;&lt;/FILE&gt;&lt;/FILE&gt;</description>
      <pubDate>Fri, 12 Nov 2010 15:23:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-to-perl-script/m-p/4712671#M659946</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2010-11-12T15:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: shell to perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-to-perl-script/m-p/4712672#M659947</link>
      <description>Oops, hit 'submit' before adding an explanation to the perl script.&lt;BR /&gt;&lt;BR /&gt;It reads a first file and for each line creates a hash array element with the whole line as key.&lt;BR /&gt;For some usages you may want to add a 'chomp' to this to remove the newline, and a uc or lc to force upper or lower case.&lt;BR /&gt;&lt;BR /&gt;Then it reads the second file iterating over that and trying each line as key into the array. If found then print, else onto the next line.&lt;BR /&gt;The 'else' could do other stuff.&lt;BR /&gt;It could also play futher with the array to create a driver table for the 'opcrag' command.&lt;BR /&gt;&lt;BR /&gt;Or when using opcarg -all, then you migh be able to use the arrays to do the right processing for the nodes reported on.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein&lt;BR /&gt;</description>
      <pubDate>Fri, 12 Nov 2010 15:28:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-to-perl-script/m-p/4712672#M659947</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2010-11-12T15:28:20Z</dc:date>
    </item>
  </channel>
</rss>

