<?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: Script help - reading mulple lines into variables from command execution in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291999#M715643</link>
    <description>&amp;amp; on the end of line means run as a detached process. |&amp;amp; means to run detached, but as a co-process. This allows read -p to get its input from the co-process. Some documentation under "man ksh"&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
    <pubDate>Tue, 01 Jun 2004 13:26:52 GMT</pubDate>
    <dc:creator>Rodney Hills</dc:creator>
    <dc:date>2004-06-01T13:26:52Z</dc:date>
    <item>
      <title>Script help - reading mulple lines into variables from command execution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291989#M715633</link>
      <description>I want to be able to execute a command, do some greps on the output and then assign the output columns to variables within a loop.  There's got to be a way to do this without saving the ouput to a file and then reading the file.&lt;BR /&gt;&lt;BR /&gt;Any examples to share?&lt;BR /&gt;&lt;BR /&gt;Thanks...&lt;BR /&gt;Jack&lt;BR /&gt;&lt;BR /&gt;----------------------------------&lt;BR /&gt;&lt;BR /&gt;Example:&lt;BR /&gt;while read -r  field1 field2 field3 field4 field5 field6 field7 field8 field9 field10&lt;BR /&gt;do&lt;BR /&gt;echo $field1&lt;BR /&gt;done &amp;lt; lanscan | grep -v "^Path" | grep -v "^Hardware" | awk ' { print $1 " " $2 " " $3 " "  $4 \ " " $5 " " $6 " "&lt;BR /&gt; $7 " " $8 " " $9  " " $10 } '&lt;BR /&gt;---------------------------------&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Jun 2004 07:50:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291989#M715633</guid>
      <dc:creator>Jack C. Mahaffey</dc:creator>
      <dc:date>2004-06-01T07:50:45Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - reading mulple lines into variables from command execution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291990#M715634</link>
      <description>How about a little perl?&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;open(INFILEPTR,"lanscan |") || die "unable to find lanscan";&lt;BR /&gt;while (&lt;INFILEPTR&gt;) {&lt;BR /&gt;   next if (grep(/^Path/,$_));&lt;BR /&gt;   next if (grep(/^Hardware/,$_));&lt;BR /&gt;   tr/  / /s;&lt;BR /&gt;   ($field1, $field2, $field3, $field4, $field5, $field6, $field7, $field8, $fie&lt;BR /&gt;ld9, $field10) = split(/ /);&lt;BR /&gt;   print $field1,"_" ,$field2,"_", $field3,"_", $field4,"_", $field5,"_", $field6,"_", $field7,"_", $field8,"_", $field9,"_", $field10;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry&lt;/INFILEPTR&gt;</description>
      <pubDate>Tue, 01 Jun 2004 08:33:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291990#M715634</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2004-06-01T08:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - reading mulple lines into variables from command execution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291991#M715635</link>
      <description>Thanks Harry..  Love the script.  I'd also like to get the shell version also.  I'll be using the perl version.&lt;BR /&gt;&lt;BR /&gt;Jack...</description>
      <pubDate>Tue, 01 Jun 2004 08:38:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291991#M715635</guid>
      <dc:creator>Jack C. Mahaffey</dc:creator>
      <dc:date>2004-06-01T08:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - reading mulple lines into variables from command execution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291992#M715636</link>
      <description>how about trying it this way&lt;BR /&gt;&lt;BR /&gt;lanscan | &lt;BR /&gt;grep -v "^Path" | &lt;BR /&gt;grep -v "^Hardware" | &lt;BR /&gt;awk ' { print $1 " " $2 " " $3 " " $4 \ " " $5 " " $6 " "$7 " " $8 " " $9 " " $10 } ' |&lt;BR /&gt;while read -r field1 field2 field3 field4 field5 field6 field7 field8 field9 field10&lt;BR /&gt;do&lt;BR /&gt;echo $field1&lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;instead of all the greps and awk you could just do&lt;BR /&gt;awk ' &lt;BR /&gt;/^Path/ {next;}&lt;BR /&gt;/^Hardware/ {next;}&lt;BR /&gt;{ print $1 " " $2 " " $3 " " $4 \ " " $5 " " $6 " "$7 " " $8 " " $9 " " $10 } '&lt;BR /&gt;&lt;BR /&gt;or &lt;BR /&gt;&lt;BR /&gt;while read -r field1 field2 field3 field4 field5 field6 field7 field8 field9 field10&lt;BR /&gt;do&lt;BR /&gt;echo $field1&lt;BR /&gt;done &amp;lt; $(lanscan | grep -v "^Path" | grep -v "^Hardware" | awk ' { print $1 " " $2 " " $3 " " $4 \ " " $5 " " $6 " "&lt;BR /&gt;$7 " " $8 " " $9 " " $10 } ')&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Jun 2004 09:29:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291992#M715636</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2004-06-01T09:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - reading mulple lines into variables from command execution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291993#M715637</link>
      <description>Curt, your first example worked.   The second did not.  I might have a typo somewhere.  &lt;BR /&gt;&lt;BR /&gt;Jack</description>
      <pubDate>Tue, 01 Jun 2004 09:54:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291993#M715637</guid>
      <dc:creator>Jack C. Mahaffey</dc:creator>
      <dc:date>2004-06-01T09:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - reading mulple lines into variables from command execution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291994#M715638</link>
      <description>second way works if you remove the&lt;BR /&gt;\&lt;BR /&gt;before the $5&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff&lt;BR /&gt;&lt;BR /&gt;lanscan | awk ' ^J/^Path/ {next;}^J/^Hardware/ {next;}^J{ print $1 " " $2 " " $3 " " $4 " " $5 " " $6 " "$7 " " $8 " " $9 " " $10 } '&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Jun 2004 10:46:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291994#M715638</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2004-06-01T10:46:42Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - reading mulple lines into variables from command execution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291995#M715639</link>
      <description>I caught the backslash... Still didn't work.   I'll check it again.</description>
      <pubDate>Tue, 01 Jun 2004 10:50:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291995#M715639</guid>
      <dc:creator>Jack C. Mahaffey</dc:creator>
      <dc:date>2004-06-01T10:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - reading mulple lines into variables from command execution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291996#M715640</link>
      <description>no i couldn't get the second example to work either, but here is another way&lt;BR /&gt;&lt;BR /&gt;lanscan | grep -v "^Path" | grep -v "^Hardware" | awk ' { print $1 " " $2 " " $3 " " $4 " " $5 " " $6 " "&lt;BR /&gt;$7 " " $8 " " $9 " " $10 } ' |&amp;amp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;while read -rp field1 field2 field3 field4 field5 field6 field7 field8 field9 field10&lt;BR /&gt;do&lt;BR /&gt;echo $field1&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;hey 2 out of 3 ain't bad</description>
      <pubDate>Tue, 01 Jun 2004 12:53:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291996#M715640</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2004-06-01T12:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - reading mulple lines into variables from command execution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291997#M715641</link>
      <description>I like the last example also.  What specifically does the "&amp;amp;" and -p do?  Is &amp;amp; a reserved variable?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Jun 2004 13:17:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291997#M715641</guid>
      <dc:creator>Jack C. Mahaffey</dc:creator>
      <dc:date>2004-06-01T13:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - reading mulple lines into variables from command execution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291998#M715642</link>
      <description>I noticed that both |&amp;amp; need concatenated with no space in order for it to work.  &lt;BR /&gt;</description>
      <pubDate>Tue, 01 Jun 2004 13:22:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291998#M715642</guid>
      <dc:creator>Jack C. Mahaffey</dc:creator>
      <dc:date>2004-06-01T13:22:03Z</dc:date>
    </item>
    <item>
      <title>Re: Script help - reading mulple lines into variables from command execution</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291999#M715643</link>
      <description>&amp;amp; on the end of line means run as a detached process. |&amp;amp; means to run detached, but as a co-process. This allows read -p to get its input from the co-process. Some documentation under "man ksh"&lt;BR /&gt; &lt;BR /&gt;-- Rod Hills</description>
      <pubDate>Tue, 01 Jun 2004 13:26:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-help-reading-mulple-lines-into-variables-from-command/m-p/3291999#M715643</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2004-06-01T13:26:52Z</dc:date>
    </item>
  </channel>
</rss>

