<?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: OK...I need some shell script help.. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498425#M830672</link>
    <description>Hi ,&lt;BR /&gt;&lt;BR /&gt;How about sorting your file on first &amp;amp; fourth field and then applying your logic.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Mon, 26 Feb 2001 21:46:03 GMT</pubDate>
    <dc:creator>Vikas Khator</dc:creator>
    <dc:date>2001-02-26T21:46:03Z</dc:date>
    <item>
      <title>OK...I need some shell script help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498424#M830671</link>
      <description>I am down to the last of this thing...and I have lost it.&lt;BR /&gt;Take a look at the attached file that is giving me a headache. This is what I've created for doing disk mapping on multiple systems. I did it on 4 servers attached to our EMC disk array..&lt;BR /&gt;Each record can have between 3-5 fields (depending on if it's attached to lvol/filesystem or not)&lt;BR /&gt;&lt;BR /&gt;What I am trying to do is get the alternate link (second line of same value as $1) to also print what is reported in the primary disk/lvol/file_sys line. &lt;BR /&gt;AND then I want to print a fairly clean report with a space in between different values of $1. Nothing fancy.&lt;BR /&gt;&lt;BR /&gt;This is that disk mapping program I have been working on....and I'm down to this...&lt;BR /&gt;..ps..can you tell I am NOT a programmer ! Everytime I try to printf...it blows up because the first line does not have a value for $4 or $5 ... arghghgh !!  I've been doing this in Posix Shell.  My code is sloppy, but it got me to here..any Help would be appreciated !!&lt;BR /&gt;&lt;BR /&gt;$1 = EMC info&lt;BR /&gt;$2 = hostname&lt;BR /&gt;$3 = disk addr info&lt;BR /&gt;$4 = /dev/vg/lvol&lt;BR /&gt;$5 = file_system&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Rita</description>
      <pubDate>Mon, 26 Feb 2001 21:25:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498424#M830671</guid>
      <dc:creator>Rita C Workman</dc:creator>
      <dc:date>2001-02-26T21:25:14Z</dc:date>
    </item>
    <item>
      <title>Re: OK...I need some shell script help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498425#M830672</link>
      <description>Hi ,&lt;BR /&gt;&lt;BR /&gt;How about sorting your file on first &amp;amp; fourth field and then applying your logic.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 26 Feb 2001 21:46:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498425#M830672</guid>
      <dc:creator>Vikas Khator</dc:creator>
      <dc:date>2001-02-26T21:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: OK...I need some shell script help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498426#M830673</link>
      <description>Actually EMC has software called I believe ECC that will do exactaly that and let you save it as a flat file, you can even import it into excell as a CSV and sort it if you want.  Or you can use the HP utility inq.HP that is a free EMC HP binary awk out each servers information sort it compare it to /etc/lvmtab to get lvol info and the append it to a file on a leveraged machine with a `hostname` placed between them.&lt;BR /&gt;</description>
      <pubDate>Mon, 26 Feb 2001 21:54:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498426#M830673</guid>
      <dc:creator>Fred Myers</dc:creator>
      <dc:date>2001-02-26T21:54:06Z</dc:date>
    </item>
    <item>
      <title>Re: OK...I need some shell script help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498427#M830674</link>
      <description>Rita,&lt;BR /&gt;&lt;BR /&gt;I'd love to help you, but it would be easier if you submit your script!&lt;BR /&gt;&lt;BR /&gt;Bye,&lt;BR /&gt;Rik.</description>
      <pubDate>Mon, 26 Feb 2001 22:10:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498427#M830674</guid>
      <dc:creator>RikTytgat</dc:creator>
      <dc:date>2001-02-26T22:10:32Z</dc:date>
    </item>
    <item>
      <title>Re: OK...I need some shell script help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498428#M830675</link>
      <description>If you're just worried about the values of $4 and $5 being null, why not just test them before calling your printf statement?  If they are null, then set them to some arbitrary value like "-" or "N/A".</description>
      <pubDate>Tue, 27 Feb 2001 00:10:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498428#M830675</guid>
      <dc:creator>James A. Donovan</dc:creator>
      <dc:date>2001-02-27T00:10:38Z</dc:date>
    </item>
    <item>
      <title>Re: OK...I need some shell script help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498429#M830676</link>
      <description>I'm not sure I get exactly what you want, but you can try this:&lt;BR /&gt;&lt;BR /&gt;awk '{if(NF==5){printf("\n%25s %10s - %s, Alt: %s\n",$4,$5,prev3,$3)}prev1=$1;prev3=$3}' name_of_your_file&lt;BR /&gt;&lt;BR /&gt;Maybe you could post what you want the output to say and look like.&lt;BR /&gt;</description>
      <pubDate>Tue, 27 Feb 2001 01:52:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498429#M830676</guid>
      <dc:creator>Tom Danzig</dc:creator>
      <dc:date>2001-02-27T01:52:05Z</dc:date>
    </item>
    <item>
      <title>Re: OK...I need some shell script help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498430#M830677</link>
      <description>Here's a POSIX/ksh script that will filter stdin into 5 parameters with missing parameters changed to " "&lt;BR /&gt;&lt;BR /&gt;---&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;# Usage:  cat somefile | parm5&lt;BR /&gt;# Output is always 5 values&lt;BR /&gt;&lt;BR /&gt;# To remove the leading : use this: &lt;BR /&gt;#   echo ${SN#:} ${HN#:} $DEV ${LVOL:-" "} ${MNT:-" "}&lt;BR /&gt;&lt;BR /&gt;while read SN HN DEV LVOL MNT&lt;BR /&gt;do&lt;BR /&gt;echo $SN $HN $DEV ${LVOL:-" "} ${MNT:-" "}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;---&lt;BR /&gt;&lt;BR /&gt;The key is using shell parameter expansion.  If LVOL or MNT are null or undefined, the result will be " " (or whatever you'd like). To use this script: &lt;BR /&gt;&lt;BR /&gt;cat InputFile | this_script&lt;BR /&gt;&lt;BR /&gt;Output will always be 5 values.  Or you can pull the snippet into your script.</description>
      <pubDate>Tue, 27 Feb 2001 02:27:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498430#M830677</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2001-02-27T02:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: OK...I need some shell script help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498431#M830678</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;What I would do:&lt;BR /&gt;&lt;BR /&gt;while read line&lt;BR /&gt;do&lt;BR /&gt;  set -- $line "" "" "" "" ""&lt;BR /&gt;done &amp;lt; your_file&lt;BR /&gt;&lt;BR /&gt;That way, $1 to $5 always get filled up, even when your line only contains 3 (or less) fields (words). The 4th and 5th word will be empty, but you will not get an error (be sure to quote your variables when doing a prinf!!)&lt;BR /&gt;&lt;BR /&gt;Hope this helps,&lt;BR /&gt;Rik.</description>
      <pubDate>Tue, 27 Feb 2001 06:26:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498431#M830678</guid>
      <dc:creator>RikTytgat</dc:creator>
      <dc:date>2001-02-27T06:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: OK...I need some shell script help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498432#M830679</link>
      <description>&lt;BR /&gt;join is  very usefull for me.&lt;BR /&gt;&lt;BR /&gt;See also: &lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/cm/QuestionAnswer/1,1150,0x5cfe6c96588ad4118fef0090279cd0f9,00.html" target="_blank"&gt;http://forums.itrc.hp.com/cm/QuestionAnswer/1,1150,0x5cfe6c96588ad4118fef0090279cd0f9,00.html&lt;/A&gt;</description>
      <pubDate>Tue, 27 Feb 2001 13:47:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498432#M830679</guid>
      <dc:creator>Carlos Fernandez Riera</dc:creator>
      <dc:date>2001-02-27T13:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: OK...I need some shell script help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498433#M830680</link>
      <description>Rita,&lt;BR /&gt;&lt;BR /&gt;a very simple printf statement in the posix shell;&lt;BR /&gt;&lt;BR /&gt;printf "%-x.xs%-x.xs%-x.xs%-x.xs%-x.xs\n" "$1" "$2" "$3" " $4" " $5"&lt;BR /&gt;&lt;BR /&gt;where -x.x is used for presentation ;o)&lt;BR /&gt;&lt;BR /&gt;by adding the space in front of $4 and $5 the argument to printf is always filled.&lt;BR /&gt;&lt;BR /&gt;Greetz, Danny.</description>
      <pubDate>Tue, 27 Feb 2001 14:14:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498433#M830680</guid>
      <dc:creator>Danny Engelbarts</dc:creator>
      <dc:date>2001-02-27T14:14:24Z</dc:date>
    </item>
    <item>
      <title>Re: OK...I need some shell script help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498434#M830681</link>
      <description>One more variant (rita.txt is your attachement):&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;EMCP=" "&lt;BR /&gt;DADDRP=" "&lt;BR /&gt;LVOLP=" "&lt;BR /&gt;FSYSP=" "&lt;BR /&gt;sort -k1,1 -kr4,4 rita.txt -o rita.txt&lt;BR /&gt;while read EMC HOST DADDR LVOL FSYS&lt;BR /&gt;do  &lt;BR /&gt;  if [ "$EMC" != "$EMCP" ]; then&lt;BR /&gt;    echo&lt;BR /&gt;  fi&lt;BR /&gt;  if [ -z "$LVOL" ]; then&lt;BR /&gt;    LVOL=$LVOLP&lt;BR /&gt;  fi&lt;BR /&gt;  if [ -z "$FSYS" ]; then&lt;BR /&gt;    FSYS=$FSYSP&lt;BR /&gt;  fi&lt;BR /&gt;  echo $EMC $HOST $DADDR $LVOL $FSYS |   awk '{printf("%-12s %-12s %-24s %-24s %-24s\n",$1,$2,$3,$4,$5)}'&lt;BR /&gt;  EMCP=$EMC&lt;BR /&gt;  DADDRP=$DADDR&lt;BR /&gt;  LVOLP=$LVOL&lt;BR /&gt;  FSYSP=$FSYS&lt;BR /&gt;done &amp;lt; rita.txt&lt;BR /&gt;</description>
      <pubDate>Tue, 27 Feb 2001 15:41:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498434#M830681</guid>
      <dc:creator>Tommy Palo</dc:creator>
      <dc:date>2001-02-27T15:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: OK...I need some shell script help..</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498435#M830682</link>
      <description>Many thanks to Mr. Hassell, I used your syntax pretty much verbatim....&lt;BR /&gt;&lt;BR /&gt;Fred - Yes, I have a utility written by someone at EMC (Halstead..) I had posted it here once when I started on this thing.  But it only lists using lvmtab, and we wanted to have the report reflect vg/lvol and file system.&lt;BR /&gt;&lt;BR /&gt;Danny, your syntax looks alot like what I was trying to do...but needed Bill's above first. &lt;BR /&gt;&lt;BR /&gt;Anyway, I got the report to print, although it isn't 'exactly' the way I want it...it's good enough and if I want to dress it up..I'll probably save my sanity and just dress it up in a spreadsheet on my PC.....&lt;BR /&gt;Again many many thanks to everyone for their input !&lt;BR /&gt;&lt;BR /&gt;/rcw</description>
      <pubDate>Tue, 27 Feb 2001 15:43:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ok-i-need-some-shell-script-help/m-p/2498435#M830682</guid>
      <dc:creator>Rita C Workman</dc:creator>
      <dc:date>2001-02-27T15:43:49Z</dc:date>
    </item>
  </channel>
</rss>

