<?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 Simple Pattern Matching Logic In Korn Shell in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409074#M352804</link>
    <description>I am trying to implement a logic which is not working,&lt;BR /&gt;&lt;BR /&gt;I have two lists, market_list and file_system_list&lt;BR /&gt;&lt;BR /&gt;cat market_list&lt;BR /&gt;ABC BCA CDA ERF RKT PFR NTO KDR KIT GGO SPT KOT VOT KDR WWL CLW OPE REG BVG YYU &lt;BR /&gt;&lt;BR /&gt;-----market_list can be in horizontal or vertical form whatever works--------&lt;BR /&gt;&lt;BR /&gt;cat file_system_list&lt;BR /&gt;&lt;BR /&gt;/usr/local/g1&lt;BR /&gt;/imrga/geotax&lt;BR /&gt;/imrga/code1&lt;BR /&gt;/imrga/vertex&lt;BR /&gt;/usr/local/matro/mea&lt;MKT&gt;82&lt;BR /&gt;/usr/local/STW/&lt;BR /&gt;/tlgop&lt;MKT&gt;&lt;BR /&gt;/tlglogs&lt;MKT&gt;&lt;BR /&gt;/imrga&lt;BR /&gt;/tglrav&lt;MKT&gt;&lt;BR /&gt;/toplogs&lt;MKT&gt;&lt;BR /&gt;/usr/local/STW/STW88&lt;BR /&gt;/topfbf&lt;MKT&gt;&lt;BR /&gt;/toplogsmae&lt;MKT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I have list of the servers which i haven't included here and i have to go all the servers and check for those filesystems for the percentage used.&lt;BR /&gt;&lt;BR /&gt;Its ok for regular filesystems but the problem is with the filesystem which has market name on it&lt;BR /&gt;&lt;BR /&gt;in my file_system_list which has &lt;MKT&gt; in the list means it can be any one of those market which i have to try with one market at a time it may exist and it may not exist depending on the server.&lt;BR /&gt;&lt;BR /&gt;how can I replace that &lt;BR /&gt;&lt;MKT&gt;  in the file_system_list with the name of the market from the market_list but one at a time and run the bdf command.&lt;BR /&gt;for example---this works but only for regular file systems not for those where I have to remove &lt;MKT&gt; by market name one at a time and test its presence in all the servers&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;work_path=`pwd`&lt;BR /&gt;tmp1=$work_path/tmp1&lt;BR /&gt;for server in `cat server_list`&lt;BR /&gt;do&lt;BR /&gt;for file_system in `cat file_system_list`&lt;BR /&gt;do&lt;BR /&gt;ssh -o 'BatchMode yes' $server "id"&lt;BR /&gt;if [ $? = 0 ] ; then&lt;BR /&gt;                                             echo "Checking File Systems Usage For $server" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;                                              echo "---&amp;gt; ---&amp;gt; --&amp;gt; --&amp;gt; --&amp;gt; --&amp;gt; On $file_system" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;                                              ssh -n $server "bdf $file_system" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;                                              if [ $? != 0 ] ; then&lt;BR /&gt;                                              echo "no $file_system in $server" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;                                              fi&lt;BR /&gt;else&lt;BR /&gt;                                              echo $server &amp;gt;&amp;gt; server_with_problems&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;echo " All File System Check Completed For $server " &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Let me know if anything is not clear,&lt;BR /&gt;&lt;BR /&gt;my problem is I am not able to get the logic to replace the &lt;MKT&gt; by the name of the market from my market_list file one at a time and check it&lt;BR /&gt;&lt;BR /&gt;thank you in advance&lt;BR /&gt;i will appreciate any help&lt;BR /&gt;&lt;BR /&gt;&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;</description>
    <pubDate>Mon, 27 Apr 2009 22:12:23 GMT</pubDate>
    <dc:creator>pareshan</dc:creator>
    <dc:date>2009-04-27T22:12:23Z</dc:date>
    <item>
      <title>Simple Pattern Matching Logic In Korn Shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409074#M352804</link>
      <description>I am trying to implement a logic which is not working,&lt;BR /&gt;&lt;BR /&gt;I have two lists, market_list and file_system_list&lt;BR /&gt;&lt;BR /&gt;cat market_list&lt;BR /&gt;ABC BCA CDA ERF RKT PFR NTO KDR KIT GGO SPT KOT VOT KDR WWL CLW OPE REG BVG YYU &lt;BR /&gt;&lt;BR /&gt;-----market_list can be in horizontal or vertical form whatever works--------&lt;BR /&gt;&lt;BR /&gt;cat file_system_list&lt;BR /&gt;&lt;BR /&gt;/usr/local/g1&lt;BR /&gt;/imrga/geotax&lt;BR /&gt;/imrga/code1&lt;BR /&gt;/imrga/vertex&lt;BR /&gt;/usr/local/matro/mea&lt;MKT&gt;82&lt;BR /&gt;/usr/local/STW/&lt;BR /&gt;/tlgop&lt;MKT&gt;&lt;BR /&gt;/tlglogs&lt;MKT&gt;&lt;BR /&gt;/imrga&lt;BR /&gt;/tglrav&lt;MKT&gt;&lt;BR /&gt;/toplogs&lt;MKT&gt;&lt;BR /&gt;/usr/local/STW/STW88&lt;BR /&gt;/topfbf&lt;MKT&gt;&lt;BR /&gt;/toplogsmae&lt;MKT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I have list of the servers which i haven't included here and i have to go all the servers and check for those filesystems for the percentage used.&lt;BR /&gt;&lt;BR /&gt;Its ok for regular filesystems but the problem is with the filesystem which has market name on it&lt;BR /&gt;&lt;BR /&gt;in my file_system_list which has &lt;MKT&gt; in the list means it can be any one of those market which i have to try with one market at a time it may exist and it may not exist depending on the server.&lt;BR /&gt;&lt;BR /&gt;how can I replace that &lt;BR /&gt;&lt;MKT&gt;  in the file_system_list with the name of the market from the market_list but one at a time and run the bdf command.&lt;BR /&gt;for example---this works but only for regular file systems not for those where I have to remove &lt;MKT&gt; by market name one at a time and test its presence in all the servers&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;work_path=`pwd`&lt;BR /&gt;tmp1=$work_path/tmp1&lt;BR /&gt;for server in `cat server_list`&lt;BR /&gt;do&lt;BR /&gt;for file_system in `cat file_system_list`&lt;BR /&gt;do&lt;BR /&gt;ssh -o 'BatchMode yes' $server "id"&lt;BR /&gt;if [ $? = 0 ] ; then&lt;BR /&gt;                                             echo "Checking File Systems Usage For $server" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;                                              echo "---&amp;gt; ---&amp;gt; --&amp;gt; --&amp;gt; --&amp;gt; --&amp;gt; On $file_system" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;                                              ssh -n $server "bdf $file_system" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;                                              if [ $? != 0 ] ; then&lt;BR /&gt;                                              echo "no $file_system in $server" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;                                              fi&lt;BR /&gt;else&lt;BR /&gt;                                              echo $server &amp;gt;&amp;gt; server_with_problems&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;echo " All File System Check Completed For $server " &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Let me know if anything is not clear,&lt;BR /&gt;&lt;BR /&gt;my problem is I am not able to get the logic to replace the &lt;MKT&gt; by the name of the market from my market_list file one at a time and check it&lt;BR /&gt;&lt;BR /&gt;thank you in advance&lt;BR /&gt;i will appreciate any help&lt;BR /&gt;&lt;BR /&gt;&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;</description>
      <pubDate>Mon, 27 Apr 2009 22:12:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409074#M352804</guid>
      <dc:creator>pareshan</dc:creator>
      <dc:date>2009-04-27T22:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Pattern Matching Logic In Korn Shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409075#M352805</link>
      <description>&lt;!--!*#--&gt;&amp;gt;I am not able to get the logic to replace the &lt;MKT&gt; by the name of the market from my market_list file one at a time and check it&lt;BR /&gt;&lt;BR /&gt;You just need another loop:&lt;BR /&gt;...&lt;BR /&gt;if [[ "$file_system" = *\&lt;MKT&gt;* ]]; then&lt;BR /&gt;   for fs in $(&amp;lt; market_list); do&lt;BR /&gt;      xx=$(echo $file_system | sed -e "s:&lt;MKT&gt;:$fs:")&lt;BR /&gt;         echo "---&amp;gt; ---&amp;gt; --&amp;gt; --&amp;gt; --&amp;gt; --&amp;gt; On $xx" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;         echo ssh -n $server "bdf $xx" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;         if [ $? -ne 0 ]; then&lt;BR /&gt;            echo "no $xx in $server" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;         fi&lt;BR /&gt;    done&lt;BR /&gt;else # existing code&lt;BR /&gt;         echo "---&amp;gt; ---&amp;gt; --&amp;gt; --&amp;gt; --&amp;gt; --&amp;gt; On $file_system" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;         echo ssh -n $server "bdf $file_system" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;         if [ $? -ne 0 ] ; then&lt;BR /&gt;            echo "no $file_system in $server" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;         fi&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Note testing the ssh result will return the bdf exit status.  This isn't the case for remsh:&lt;BR /&gt;Note that the return value of remsh bears no&lt;BR /&gt;relation to the return value of the remote command.&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;</description>
      <pubDate>Tue, 28 Apr 2009 03:32:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409075#M352805</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-04-28T03:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Pattern Matching Logic In Korn Shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409076#M352806</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I would loop just over the server list to get a complete bdf-output of each single server (much less ssh traffic) and then would parse that output.&lt;BR /&gt;- I would initialize an array with the real filsystem names and check against the bdf data.&lt;BR /&gt;- I assume the filesystem is the last field of the bdf-output, which I remove form this array&lt;BR /&gt;- the remaining array elements (if any) are the missing entries.&lt;BR /&gt;&lt;BR /&gt;awk -v mkt="$(tr '\012' ' ' while ((getline &lt;FSLIST&gt;") for(i=1;i&amp;lt;=mk;i++) {fs2chk[++f]=$0; sub("&lt;MKT&gt;",mktlst[i],fs2chk[++f])} else fs2chk[++f]=$0}&lt;BR /&gt;# now create an associative array&lt;BR /&gt;for(n=1;n&amp;lt;=f;n++) myfs2ck[fs2chk[n]]=fs2chk[n]}&lt;BR /&gt;NF&amp;gt;3 {delete myfs2ck[$NF]}&lt;BR /&gt;END { for (fsmis in myfs2ck) print "missing",fsmis}' bdf-outputfile&lt;BR /&gt;&lt;BR /&gt;mfG Peter&lt;BR /&gt;&lt;BR /&gt;PS. This code is not really tested ...&lt;/MKT&gt;&lt;/FSLIST&gt;</description>
      <pubDate>Tue, 28 Apr 2009 17:15:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409076#M352806</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2009-04-28T17:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Pattern Matching Logic In Korn Shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409077#M352807</link>
      <description>Thanks Danny,&lt;BR /&gt;&lt;BR /&gt;Its working but in else instead of &lt;BR /&gt;&lt;BR /&gt;---&lt;BR /&gt;else&lt;BR /&gt;echo $server &amp;gt;&amp;gt; server_with_problems&lt;BR /&gt;&lt;BR /&gt;it just should be &lt;BR /&gt;else&lt;BR /&gt;$server &amp;gt;&amp;gt; server_with_problems&lt;BR /&gt;i guess.&lt;BR /&gt;&lt;BR /&gt;Nikita,&lt;BR /&gt;&lt;BR /&gt;I am trying to understand the one you provided.&lt;BR /&gt;sounds good as can reduce the traffice and may be looks efficient too but not working in mine.&lt;BR /&gt;&lt;BR /&gt;Could you explain me better&lt;BR /&gt;thanks&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Apr 2009 20:43:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409077#M352807</guid>
      <dc:creator>pareshan</dc:creator>
      <dc:date>2009-04-28T20:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Pattern Matching Logic In Korn Shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409078#M352808</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;would you please tell me, WHAT is not working for you? Could you send me the output for the run of one server?&lt;BR /&gt;&lt;BR /&gt;mfG Peter</description>
      <pubDate>Tue, 28 Apr 2009 20:48:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409078#M352808</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2009-04-28T20:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Pattern Matching Logic In Korn Shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409079#M352809</link>
      <description>I dint get a whole idea of the script&lt;BR /&gt;I mean how to run where to start where does it ends&lt;BR /&gt;&lt;BR /&gt;when i run it in my terminal as it is provided by you&lt;BR /&gt;it says&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;niki.ksh&lt;BR /&gt;niki.ksh[2]: /tmp/market_lst: Cannot find or open the file.&lt;BR /&gt;MK=0&lt;BR /&gt;awk: Cannot find or open file bdf-outputfile.&lt;BR /&gt; The source line number is 1.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 28 Apr 2009 21:01:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409079#M352809</guid>
      <dc:creator>pareshan</dc:creator>
      <dc:date>2009-04-28T21:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Pattern Matching Logic In Korn Shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409080#M352810</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I expected, you could puzzle the parts together by yourself - ok. Of course, you'll have to provide YOUR filenames, not mine.&lt;BR /&gt;I use plain filenames now - please modify them, if needed!&lt;BR /&gt;&lt;BR /&gt;Modify your script this way:&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;work_path=`pwd`&lt;BR /&gt;tmp1=$work_path/tmp1&lt;BR /&gt;for server in `cat server_list`&lt;BR /&gt;do&lt;BR /&gt;echo "Checking File Systems Usage For $server" &lt;BR /&gt;ssh -n $server "bdf" &amp;gt; $tmp1&lt;BR /&gt;if [ $? != 0 ] ; then&lt;BR /&gt;awk -v mkt="$(tr '\012' ' ' &lt;MARKET_LST&gt;&lt;/MARKET_LST&gt;while ((getline &lt;FSLIST&gt;") for(i=1;i&amp;lt;=mk;i++) {fs2chk[++f]=$0; sub("&lt;MKT&gt;",mktlst[i],fs2chk[++f])} else fs2chk[++f]=$0}&lt;BR /&gt;# now create an associative array&lt;BR /&gt;for(n=1;n&amp;lt;=f;n++) myfs2ck[fs2chk[n]]=fs2chk[n]}&lt;BR /&gt;NF&amp;gt;3 {delete myfs2ck[$NF]}&lt;BR /&gt;END { for (fsmis in myfs2ck) print "missing",fsmis}' $tmp1&lt;BR /&gt;fi&lt;BR /&gt;echo " All File System Check Completed For $server "&lt;BR /&gt;&lt;BR /&gt;done&lt;/MKT&gt;&lt;/FSLIST&gt;</description>
      <pubDate>Tue, 28 Apr 2009 21:16:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409080#M352810</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2009-04-28T21:16:29Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Pattern Matching Logic In Korn Shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409081#M352811</link>
      <description>&amp;gt;It's working but in else instead of ...&lt;BR /&gt;&amp;gt;it just should be&lt;BR /&gt;$server &amp;gt;&amp;gt; server_with_problems&lt;BR /&gt;&lt;BR /&gt;I'm not sure why you would want to leave out the echo?  I left out everything except the innermost for loop.&lt;BR /&gt;&lt;BR /&gt;You can also take that loop out and expand the files in file_system_list once, then just have the two for loops.</description>
      <pubDate>Tue, 28 Apr 2009 22:38:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409081#M352811</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-04-28T22:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Pattern Matching Logic In Korn Shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409082#M352812</link>
      <description>Nikita,&lt;BR /&gt;Thanks alot it did run but I am not sure whether I am not understanding you or you dint get my problem.&lt;BR /&gt;&lt;BR /&gt;I need to go to all the servers Listed in server_list &lt;BR /&gt;and check for those file systems and their usages (bdf) &lt;BR /&gt;listed in&lt;BR /&gt;file_system_list&lt;BR /&gt;&lt;BR /&gt;And in those file systems some of them have &lt;MKT&gt; attached at the end and for thos I have to repalce that &lt;MKT&gt; with the markets name from market_list one at a time and check existance of that file system, if exist it should give me a value of bdf otherwise it should print in the file itself or in other file there is no file system by that name in that particular server.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;As far as I know what you are doing you are doing bdf first and with the name of the file systems there you are trying to match with the filesystem I have in the list?&lt;BR /&gt;&lt;BR /&gt;But there should be somewhere to print all the result&lt;BR /&gt;&lt;BR /&gt;see this is a complete script for the whole thing which is working 100 percent fine just its taking alot of time and I thought your one can solve my problem..&lt;BR /&gt;&lt;BR /&gt;script&lt;BR /&gt;______________&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;#set -xv&lt;BR /&gt;work_path=`pwd`&lt;BR /&gt;echo $work_path&lt;BR /&gt;tmp1=$work_path/tmp1&lt;BR /&gt;&lt;BR /&gt;for server in `cat server_list`; do&lt;BR /&gt;for file_system in `cat file_system_list`; do&lt;BR /&gt;        ssh -o 'BatchMode yes' $server "id"&lt;BR /&gt;        if [ $? = 0 ] ; then&lt;BR /&gt;                echo "Checking File Systems Usage For $server" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;                echo $file_system&lt;BR /&gt;                        if [[ "$file_system" = *\&lt;MKT&gt;* ]]; then&lt;BR /&gt;                        for fs in $(&amp;lt; market_list); do&lt;BR /&gt;                                xx=$(echo $file_system | sed -e "s:&lt;MKT&gt;:$fs:")&lt;BR /&gt;                                echo "---&amp;gt; ---&amp;gt; --&amp;gt; --&amp;gt; --&amp;gt; --&amp;gt; On $xx" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;##                              echo ssh -n $server "bdf $xx" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;                                ssh -n $server "bdf $xx" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;                                        if [ $? -ne 0 ]; then&lt;BR /&gt;                                                echo "no $xx in $server" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;                                        fi&lt;BR /&gt;                        done&lt;BR /&gt;                        else&lt;BR /&gt;##if [ echo $file_system | grep mkt|wc -l = 0 ]; then&lt;BR /&gt;                                echo "---&amp;gt; ---&amp;gt; --&amp;gt; --&amp;gt; --&amp;gt; --&amp;gt; On $file_system" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;                                ssh -n $server "bdf $file_system" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;                                        if [ $? != 0 ] ; then&lt;BR /&gt;                                                echo "no $file_system in $server" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;                                        fi      &lt;BR /&gt;                        fi      &lt;BR /&gt;        else&lt;BR /&gt;                echo $server &amp;gt;&amp;gt; server_with_problems&lt;BR /&gt;        fi&lt;BR /&gt;done&lt;BR /&gt;echo " All File System Check Completed For $server " &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;---------------&lt;BR /&gt;&lt;BR /&gt;Danny,&lt;BR /&gt;I have one questoin here, everything is fine but its taking long time (really long like hours) and the output is so huge because of so many servers and I am trying to make it more efficient.&lt;BR /&gt;&lt;BR /&gt;I have like 200 servers where I need to run the script so I have divided all the servers by types&lt;BR /&gt;and I made the file called&lt;BR /&gt;server_type&lt;BR /&gt;which contains the type like&lt;BR /&gt;&lt;BR /&gt;$ cat server_type &lt;BR /&gt;NG1&lt;BR /&gt;NG2&lt;BR /&gt;TopDB&lt;BR /&gt;TopDBHA&lt;BR /&gt;CUSTOMER&lt;BR /&gt;BATCH1&lt;BR /&gt;BATCH1bu&lt;BR /&gt;MAFGGDB&lt;BR /&gt;MAFGDB&lt;BR /&gt;REPORT&lt;BR /&gt;TUXEDO1&lt;BR /&gt;TUXEDO2&lt;BR /&gt;TUXEDO3&lt;BR /&gt;TUXEDO4&lt;BR /&gt;USAGEDB&lt;BR /&gt;USAGE1&lt;BR /&gt;USAGE2&lt;BR /&gt;USAGE3&lt;BR /&gt;USAGE4&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;and I also have a file name by those types which has the list of servers under those types&lt;BR /&gt;&lt;BR /&gt;like&lt;BR /&gt;$ cat REPORT&lt;BR /&gt;bhpcrpt&lt;BR /&gt;bhperpt&lt;BR /&gt;bhpind3&lt;BR /&gt;bhpnbi3&lt;BR /&gt;dhpbos3&lt;BR /&gt;dhpcrpt&lt;BR /&gt;olyeller&lt;BR /&gt;uhpcrpt&lt;BR /&gt;&lt;BR /&gt;$ cat USAGE1&lt;BR /&gt;ind2&lt;BR /&gt;bi2a        &lt;BR /&gt;rtg10        &lt;BR /&gt;rtg12        &lt;BR /&gt;rtg8 &lt;BR /&gt;ckett        &lt;BR /&gt;alh2 &lt;BR /&gt;bos2 &lt;BR /&gt;dhpm2 &lt;BR /&gt;dha2a                &lt;BR /&gt;frod   &lt;BR /&gt;gucho &lt;BR /&gt;maattn        &lt;BR /&gt;moear     &lt;BR /&gt;pecdfr   &lt;BR /&gt;riin10        &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;and like that.&lt;BR /&gt;&lt;BR /&gt;Now I am thinking to change that code into like this&lt;BR /&gt;&lt;BR /&gt;-----------------&lt;BR /&gt;$ cat file_sys_report.ksh&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;#set -xv&lt;BR /&gt;work_path=`pwd`&lt;BR /&gt;echo $work_path&lt;BR /&gt;tmp1=$work_path/tmp1&lt;BR /&gt;&lt;BR /&gt;for st in `cat server_type`; do&lt;BR /&gt;##for server in `cat server_list`; do&lt;BR /&gt;for server in `$st`; do&lt;BR /&gt;&lt;BR /&gt;for file_system in `cat file_system_list`; do&lt;BR /&gt;        ssh -o 'BatchMode yes' $server "id"&lt;BR /&gt;        if [ $? = 0 ] ; then&lt;BR /&gt;                echo "Checking File Systems Usage For $server" &amp;gt;&amp;gt; $tmp1_$st&lt;BR /&gt;                echo $file_system&lt;BR /&gt;                        if [[ "$file_system" = *\&lt;MKT&gt;* ]]; then&lt;BR /&gt;                        for fs in $(&amp;lt; market_list); do&lt;BR /&gt;                                xx=$(echo $file_system | sed -e "s:&lt;MKT&gt;:$fs:")&lt;BR /&gt;                                echo "---&amp;gt; ---&amp;gt; --&amp;gt; --&amp;gt; --&amp;gt; --&amp;gt; On $xx" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;##                              echo ssh -n $server "bdf $xx" &amp;gt;&amp;gt; $tmp1_$st&lt;BR /&gt;                                ssh -n $server "bdf $xx" &amp;gt;&amp;gt; $tmp1_$st&lt;BR /&gt;                                        if [ $? -ne 0 ]; then&lt;BR /&gt;                                                echo "no $xx in $server" &amp;gt;&amp;gt; $tmp1_$st&lt;BR /&gt;                                        fi&lt;BR /&gt;                        done&lt;BR /&gt;                        else&lt;BR /&gt;##if [ echo $file_system | grep mkt|wc -l = 0 ]; then&lt;BR /&gt;                                echo "---&amp;gt; ---&amp;gt; --&amp;gt; --&amp;gt; --&amp;gt; --&amp;gt; On $file_system" &amp;gt;&amp;gt; $tmp1_$st&lt;BR /&gt;                                ssh -n $server "bdf $file_system" &amp;gt;&amp;gt; $tmp1_$st&lt;BR /&gt;                                        if [ $? != 0 ] ; then&lt;BR /&gt;                                                echo "no $file_system in $server" &amp;gt;&amp;gt; $tmp1_$st&lt;BR /&gt;                                        fi      &lt;BR /&gt;                        fi      &lt;BR /&gt;        else&lt;BR /&gt;                echo $server &amp;gt;&amp;gt; server_with_problems&lt;BR /&gt;        fi&lt;BR /&gt;done&lt;BR /&gt;echo " All File System Check Completed For $server " &amp;gt;&amp;gt; $tmp1_$st&lt;BR /&gt;done&lt;BR /&gt;done&lt;BR /&gt;-------------------&lt;BR /&gt;&lt;BR /&gt;but its not working I guess, it says those servers not found&lt;BR /&gt;this is a part of the error which is too long&lt;BR /&gt;&lt;BR /&gt;CUSTOMER: bowie:  not found&lt;BR /&gt;CUSTOMER[2]: dhpalh1:  not found&lt;BR /&gt;CUSTOMER[3]: ferguson:  not found&lt;BR /&gt;CUSTOMER[4]: larry:  not found&lt;BR /&gt;CUSTOMER[5]: rubble:  not found&lt;BR /&gt;CUSTOMER[6]: thaspen:  not found&lt;BR /&gt;BATCH1: bhptlg66:  not found&lt;BR /&gt;BATCH1[2]: bhptlg72:  not found&lt;BR /&gt;BATCH1[3]: bhptlga4:  not found&lt;BR /&gt;BATCH1[4]: bhptlga7:  not found&lt;BR /&gt;BATCH1[5]: dhptg45a:  not found&lt;BR /&gt;BATCH1[6]: dhptg46a:  not found&lt;BR /&gt;BATCH1[7]: dhptg47a:  not found&lt;BR /&gt;BATCH1[8]: dhptg48a:  not found&lt;BR /&gt;BATCH1[9]: uhptlg18:  not found&lt;BR /&gt;BATCH1bu: bhptlg67:  not found&lt;BR /&gt;BATCH1bu[2]: bhptlg70:  not found&lt;BR /&gt;BATCH1bu[3]: dhptg45b:  not found&lt;BR /&gt;BATCH1bu[4]: dhptg46b:  not found&lt;BR /&gt;BATCH1bu[5]: dhptg47b:  not found&lt;BR /&gt;BATCH1bu[6]: dhptg48b:  not found&lt;BR /&gt;BATCH1bu[7]: uhptlg21:  not found&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;So I am wondering what is wrong there and how other way to make it efficient??&lt;BR /&gt;&lt;BR /&gt;Thanks Alot&lt;BR /&gt;Appreciate Any Help&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;&lt;/MKT&gt;</description>
      <pubDate>Tue, 28 Apr 2009 23:00:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409082#M352812</guid>
      <dc:creator>pareshan</dc:creator>
      <dc:date>2009-04-28T23:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Pattern Matching Logic In Korn Shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409083#M352813</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;I just wanted to point out that it's "Dennis" and NOT "Danny" to whom you refer.&lt;BR /&gt;&lt;BR /&gt;Secondly, I'm honored that you named a server after me! viz.&lt;BR /&gt;&lt;BR /&gt;CUSTOMER[3]: ferguson:&lt;BR /&gt;&lt;BR /&gt;:-}}&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 28 Apr 2009 23:21:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409083#M352813</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-04-28T23:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Pattern Matching Logic In Korn Shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409084#M352814</link>
      <description>&lt;!--!*#--&gt;This version computes the filesystems once:&lt;BR /&gt;work_path=$PWD&lt;BR /&gt;FS_LIST=/var/tmp/file_system_list2&lt;BR /&gt;tmp1=$work_path/tmp1&lt;BR /&gt;# compute filesystems&lt;BR /&gt;for file_system in $(&amp;lt; file_system_list); do&lt;BR /&gt;   if [[ "$file_system" = *\&lt;MKT&gt;* ]]; then&lt;BR /&gt;      for fs in $(&amp;lt; market_list); do&lt;BR /&gt;         echo $file_system | sed -e "s:&lt;MKT&gt;:$fs:"&lt;BR /&gt;      done&lt;BR /&gt;   else&lt;BR /&gt;      echo "$file_system"&lt;BR /&gt;   fi&lt;BR /&gt;done &amp;gt; $FS_LIST&lt;BR /&gt;&lt;BR /&gt;for server in $(&amp;lt; server_list); do&lt;BR /&gt;   ssh -o "BatchMode yes" $server "id"&lt;BR /&gt;   if [ $? -eq 0 ]; then&lt;BR /&gt;      echo "Checking File Systems Usage For $server" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;      for file_system in $(&amp;lt; $FS_LIST); do&lt;BR /&gt;         echo "---&amp;gt; ---&amp;gt; --&amp;gt; --&amp;gt; --&amp;gt; --&amp;gt; On $file_system" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;         ssh -n $server "bdf $file_system" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;         if [ $? -ne 0 ] ; then&lt;BR /&gt;            echo "no $file_system in $server" &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;         fi&lt;BR /&gt;      done&lt;BR /&gt;   else&lt;BR /&gt;      echo $server &amp;gt;&amp;gt; server_with_problems&lt;BR /&gt;   fi&lt;BR /&gt;   echo " All File System Check Completed For $server " &amp;gt;&amp;gt; $tmp1&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;rm -f $FS_LIST&lt;BR /&gt;&lt;BR /&gt;I pulled the first ssh out of the inner loop.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;it's taking long time and the output is so huge because of so many servers and I am trying to make it more efficient.&lt;BR /&gt;&lt;BR /&gt;If you need that huge output, you need to take a long time.&lt;BR /&gt;&lt;BR /&gt;Does each server really have all of those filesystems?  Or are some over NFS?  If they are, there is no need to run bdf on them more than once.  Ideally do it only on the server, otherwise on one client.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;I have like 200 servers where I need to run the script so I have divided all the servers by types and I made the file called&lt;BR /&gt;server_type&lt;BR /&gt;&lt;BR /&gt;I'm not sure how that helps, unless you are only doing some at a time?  Or you are doing them in parallel?&lt;BR /&gt;&lt;BR /&gt;&amp;gt;it says those servers not found this is a part of the error which is too long&lt;BR /&gt;CUSTOMER: bowie: not found&lt;BR /&gt;&lt;BR /&gt;Your second for loop syntax is wrong:&lt;BR /&gt;for st in $(&amp;lt; server_type); do&lt;BR /&gt;   for server in $(&amp;lt; $st); do&lt;BR /&gt;&lt;BR /&gt;You should also not use `` but use the easier to read $().&lt;BR /&gt;&lt;BR /&gt;Note: This will not speed things up, nor shorten the output.  You'll still be doing 200 servers.&lt;/MKT&gt;&lt;/MKT&gt;</description>
      <pubDate>Wed, 29 Apr 2009 01:43:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409084#M352814</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-04-29T01:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Pattern Matching Logic In Korn Shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409085#M352815</link>
      <description>Hi Pareshan,&lt;BR /&gt;&lt;BR /&gt;now it is clear, that&lt;BR /&gt;- you don't want to check, if there are filsystem missing&lt;BR /&gt;- not all possible filesystem names constructed by substituting '&lt;MKT&gt;' with all pattern of the list must exist&lt;BR /&gt;- you want to match filesystem names against some pattern&lt;BR /&gt;- report their diskusage&lt;BR /&gt;&lt;BR /&gt;Now try:&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;work_path=`pwd`&lt;BR /&gt;tmp1=$work_path/tmp1&lt;BR /&gt;tmp2=$work_path/dftmp&lt;BR /&gt;for server in `cat server_list`&lt;BR /&gt;do&lt;BR /&gt;echo "Checking File Systems Usage For $server"&lt;BR /&gt;ssh -n $server "bdf" &amp;gt; $tmp2&lt;BR /&gt;if [ $? != 0 ] ; then&lt;BR /&gt;awk -v mkt="$(tr '\012' ' ' &lt;MARKET_LST&gt;&lt;/MARKET_LST&gt;while ((getline &lt;FSLIST&gt;") for(i=1;i&amp;lt;=mk;i++) {fs2chk[++f]=$0; sub("&lt;MKT&gt;",mktlst[i],fs2chk[++f])} else fs2chk[++f]=$0}&lt;BR /&gt;# now create an associative array&lt;BR /&gt;for(n=1;n&amp;lt;=f;n++) myfs2ck[fs2chk[n]]=fs2chk[n]}&lt;BR /&gt;NF&amp;gt;3 {if(myfs2ck[$NF]) reportfs[$NF]=$0}&lt;BR /&gt;END { for (fs in reportfs) print reportfs[fs]}' $tmp2&lt;BR /&gt;fi&lt;BR /&gt;echo " All File System Check Completed For $server "&lt;BR /&gt;done | tee $tmp1&lt;BR /&gt;&lt;BR /&gt;mfG Peter&lt;BR /&gt;PS: drop the 'tee' command, when there is no need to watch what happens during the runtime of this script; use&lt;BR /&gt;...&lt;BR /&gt;done &amp;gt;$tmp&lt;BR /&gt;instead then.&lt;/MKT&gt;&lt;/FSLIST&gt;&lt;/MKT&gt;</description>
      <pubDate>Wed, 29 Apr 2009 06:41:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409085#M352815</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2009-04-29T06:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Simple Pattern Matching Logic In Korn Shell</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409086#M352816</link>
      <description>Hi pareshan,&lt;BR /&gt;&lt;BR /&gt;one follow up:&lt;BR /&gt;If all filesystems in play are local, use&lt;BR /&gt;bdf -l&lt;BR /&gt;as command - this can limit the output and speed up things.&lt;BR /&gt;&lt;BR /&gt;mfG PETER</description>
      <pubDate>Wed, 29 Apr 2009 06:45:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/simple-pattern-matching-logic-in-korn-shell/m-p/4409086#M352816</guid>
      <dc:creator>Peter Nikitka</dc:creator>
      <dc:date>2009-04-29T06:45:43Z</dc:date>
    </item>
  </channel>
</rss>

