<?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: Feedback requested on output format for scripting in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/feedback-requested-on-output-format-for-scripting/m-p/3566172#M702591</link>
    <description>I would personally prefer option 2, BUT I would prefer that each attribute be on a separate line.&lt;BR /&gt;&lt;BR /&gt;&lt;ATTR1&gt;=&lt;VAL1&gt;&lt;BR /&gt;&lt;ATTR2&gt;=&lt;VAL2&gt;&lt;BR /&gt;&lt;BR /&gt;Also, what happens if a particular attribute doesn't exist or has no value?  Hopefully there is some sort of place holder or string to indicate each case?&lt;BR /&gt;&lt;BR /&gt;A variation on option2 may also work if each value is on a separate line.&lt;BR /&gt;&lt;BR /&gt;&lt;VAL1&gt;&lt;BR /&gt;&lt;VAL2&gt;&lt;BR /&gt;&lt;BR /&gt;As long as a non-existant attribute or null attribute value is indicated.&lt;BR /&gt;&lt;BR /&gt;My 2nd option can be handy for scripting if doing:&lt;BR /&gt;&lt;BR /&gt;while read LINE&lt;BR /&gt;do&lt;BR /&gt;DO YOUR STUFF&lt;BR /&gt;done &amp;lt; cmd get -a attr1 -a attr2 -a attr3&lt;BR /&gt;&lt;BR /&gt;or something to that effect. That way you have each value on a separate line and can act accordingly if needed.&lt;/VAL2&gt;&lt;/VAL1&gt;&lt;/VAL2&gt;&lt;/ATTR2&gt;&lt;/VAL1&gt;&lt;/ATTR1&gt;</description>
    <pubDate>Fri, 17 Jun 2005 11:54:04 GMT</pubDate>
    <dc:creator>Patrick Wallek</dc:creator>
    <dc:date>2005-06-17T11:54:04Z</dc:date>
    <item>
      <title>Feedback requested on output format for scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/feedback-requested-on-output-format-for-scripting/m-p/3566171#M702590</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;HP is designing a new function for an HP-UX command. This option would allow to pass a number of attribute names to the command, and the command output would display the associated values. This functionality would mostly be used in script mode, so we are looking for feedback on what is the best format to manage the output from a script.&lt;BR /&gt; &lt;BR /&gt;Command:&lt;BR /&gt;cmd get -a &lt;ATTR1&gt; -a &lt;ATTR2&gt; ... -a &lt;ATTRN&gt;&lt;BR /&gt;&lt;BR /&gt;Output choices: &lt;BR /&gt;&lt;BR /&gt;1) values only:&lt;BR /&gt;&lt;VAL1&gt; : &lt;VAL2&gt; : ... : &lt;VALN&gt;&lt;BR /&gt;&lt;BR /&gt;2) attr names + values:&lt;BR /&gt;&lt;ATTR1&gt;=&lt;VAL1&gt; : &lt;ATTR2&gt;=&lt;VAL2&gt; : ...&lt;BR /&gt;&lt;BR /&gt;3) attr names then values on a new line:&lt;BR /&gt;&lt;ATTR1&gt; : &lt;ATTR2&gt; : .. : &lt;ATTRN&gt;&lt;BR /&gt;&lt;VAL1&gt; : &lt;VAL2&gt; : ... : &lt;VALN&gt;&lt;BR /&gt;&lt;BR /&gt;4) other proposal?&lt;BR /&gt;&lt;BR /&gt;which is best and why?&lt;BR /&gt;&lt;BR /&gt;Thanks!&lt;BR /&gt;&lt;BR /&gt;Marie-Noelle&lt;BR /&gt;&lt;/VALN&gt;&lt;/VAL2&gt;&lt;/VAL1&gt;&lt;/ATTRN&gt;&lt;/ATTR2&gt;&lt;/ATTR1&gt;&lt;/VAL2&gt;&lt;/ATTR2&gt;&lt;/VAL1&gt;&lt;/ATTR1&gt;&lt;/VALN&gt;&lt;/VAL2&gt;&lt;/VAL1&gt;&lt;/ATTRN&gt;&lt;/ATTR2&gt;&lt;/ATTR1&gt;</description>
      <pubDate>Fri, 17 Jun 2005 11:37:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/feedback-requested-on-output-format-for-scripting/m-p/3566171#M702590</guid>
      <dc:creator>marie-noelle jeanson_1</dc:creator>
      <dc:date>2005-06-17T11:37:18Z</dc:date>
    </item>
    <item>
      <title>Re: Feedback requested on output format for scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/feedback-requested-on-output-format-for-scripting/m-p/3566172#M702591</link>
      <description>I would personally prefer option 2, BUT I would prefer that each attribute be on a separate line.&lt;BR /&gt;&lt;BR /&gt;&lt;ATTR1&gt;=&lt;VAL1&gt;&lt;BR /&gt;&lt;ATTR2&gt;=&lt;VAL2&gt;&lt;BR /&gt;&lt;BR /&gt;Also, what happens if a particular attribute doesn't exist or has no value?  Hopefully there is some sort of place holder or string to indicate each case?&lt;BR /&gt;&lt;BR /&gt;A variation on option2 may also work if each value is on a separate line.&lt;BR /&gt;&lt;BR /&gt;&lt;VAL1&gt;&lt;BR /&gt;&lt;VAL2&gt;&lt;BR /&gt;&lt;BR /&gt;As long as a non-existant attribute or null attribute value is indicated.&lt;BR /&gt;&lt;BR /&gt;My 2nd option can be handy for scripting if doing:&lt;BR /&gt;&lt;BR /&gt;while read LINE&lt;BR /&gt;do&lt;BR /&gt;DO YOUR STUFF&lt;BR /&gt;done &amp;lt; cmd get -a attr1 -a attr2 -a attr3&lt;BR /&gt;&lt;BR /&gt;or something to that effect. That way you have each value on a separate line and can act accordingly if needed.&lt;/VAL2&gt;&lt;/VAL1&gt;&lt;/VAL2&gt;&lt;/ATTR2&gt;&lt;/VAL1&gt;&lt;/ATTR1&gt;</description>
      <pubDate>Fri, 17 Jun 2005 11:54:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/feedback-requested-on-output-format-for-scripting/m-p/3566172#M702591</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2005-06-17T11:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: Feedback requested on output format for scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/feedback-requested-on-output-format-for-scripting/m-p/3566173#M702593</link>
      <description>I would go for the second form. If it used by script, I imagine it has to be easily parsed, and it seems to me that second form will be the best for that. Maybe separated by newlines instead of ':', but that's not really important. &lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Fred&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Jun 2005 11:59:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/feedback-requested-on-output-format-for-scripting/m-p/3566173#M702593</guid>
      <dc:creator>Fred Ruffet</dc:creator>
      <dc:date>2005-06-17T11:59:04Z</dc:date>
    </item>
    <item>
      <title>Re: Feedback requested on output format for scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/feedback-requested-on-output-format-for-scripting/m-p/3566174#M702595</link>
      <description>My choice would be all on one line for easy processing by Perl or awk and I would only want the values BUT the separator should be a &lt;TAB&gt; because that is nicely visible whitespace but unlike ':', ',', or &lt;SPACE&gt;, &lt;TAB&gt; would be an extremely unlikely character to be embedded within a value. &lt;BR /&gt;&lt;BR /&gt;&lt;VAL1&gt;&lt;TAB&gt;&lt;VAL2&gt;&lt;TAB&gt; ... &lt;VALN&gt;&lt;BR /&gt;&lt;BR /&gt;It's also trivially easily to parse the line with Perl, awk, or the shell with &lt;TAB&gt; as the field separator. &lt;TAB&gt; is always my weapon of choice for this.&lt;/TAB&gt;&lt;/TAB&gt;&lt;/VALN&gt;&lt;/TAB&gt;&lt;/VAL2&gt;&lt;/TAB&gt;&lt;/VAL1&gt;&lt;/TAB&gt;&lt;/SPACE&gt;&lt;/TAB&gt;</description>
      <pubDate>Fri, 17 Jun 2005 12:07:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/feedback-requested-on-output-format-for-scripting/m-p/3566174#M702595</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-06-17T12:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: Feedback requested on output format for scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/feedback-requested-on-output-format-for-scripting/m-p/3566175#M702596</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;1. Since this function is going to be used in scriting i would go for listing the attributes in one single line so that they can be used easily for further processing. &lt;BR /&gt;2. I would prefer to have one more option for having attribute name displayed with value and the other one only the value which should be default.&lt;BR /&gt;e.g. i would add one more switch say v to the command to get attribute name along with the value and by default it should only display the value.&lt;BR /&gt;&lt;BR /&gt;a) cmd get -a &lt;ATTR1&gt; -a &lt;ATTR2&gt; ... &lt;BR /&gt;&lt;VALUE1&gt;:&lt;VALUE2&gt;:&lt;VALUE3&gt;:...&lt;BR /&gt;&lt;BR /&gt;b) cmd get -v -a &lt;ATTR1&gt; -a &lt;ATTR2&gt; ... &lt;BR /&gt;&lt;ATTR1&gt;:&lt;ATTR2&gt;:&lt;ATTR3&gt;:.....&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;/ATTR3&gt;&lt;/ATTR2&gt;&lt;/ATTR1&gt;&lt;/ATTR2&gt;&lt;/ATTR1&gt;&lt;/VALUE3&gt;&lt;/VALUE2&gt;&lt;/VALUE1&gt;&lt;/ATTR2&gt;&lt;/ATTR1&gt;</description>
      <pubDate>Fri, 17 Jun 2005 13:55:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/feedback-requested-on-output-format-for-scripting/m-p/3566175#M702596</guid>
      <dc:creator>Bharat Katkar</dc:creator>
      <dc:date>2005-06-17T13:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: Feedback requested on output format for scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/feedback-requested-on-output-format-for-scripting/m-p/3566176#M702597</link>
      <description>I like the simple option 1) because supposedly my script asked for the atributes in a given order and knows to receive them in that order.&lt;BR /&gt;&lt;BR /&gt;As Clay hints to, the prefered seperator might not be obvious. Why not have that be a command line option like AWKs -F. A good default would be TAB.&lt;BR /&gt;&lt;BR /&gt;The parsing now is simple READ.&lt;BR /&gt;The basic Perl parsing now is a very simple:&lt;BR /&gt;&lt;BR /&gt;@val=split /\t/, `$command`&lt;BR /&gt;or with no spaces in the values:&lt;BR /&gt;$_ = `$command`;&lt;BR /&gt;@val=split;&lt;BR /&gt;&lt;BR /&gt;If this is an option which generates multiple, popular, attributes (like ps -ef) then a header line is needed. This could be implied by such multi-attribute selection.&lt;BR /&gt;You then just pre-parse the attributes and turn them into string/keyed indexes. In Perl:&lt;BR /&gt;&lt;BR /&gt;$_=&amp;lt;&amp;gt;;&lt;BR /&gt;@attrs=split; &lt;BR /&gt;$i=0; &lt;BR /&gt;$attr{$a}=$i++ while($attrs[$i]};&lt;BR /&gt;$_=&amp;lt;&amp;gt;;&lt;BR /&gt;@val=split; &lt;BR /&gt;print $val[$attr{"attr2"}]."\n"&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;@attrs=split /\t/,&amp;lt;&amp;gt;;&lt;BR /&gt;for ($i=0;$i&amp;lt;@attrs;$i++) {$attr{$attrs[$i]}=$i};&lt;BR /&gt;@val=split /\t/,&amp;lt;&amp;gt;;&lt;BR /&gt;print $val[$attr{"attr2"}]."\n"&lt;BR /&gt;&lt;BR /&gt;btw... I noticed one minor catch with a TAB versus the simple perl whitespace split. With an explicit split on TAB the potential newline after the last field become part of the field, so needs to be 'chomped' first:&lt;BR /&gt;&lt;BR /&gt;$_=&amp;lt;&amp;gt;;&lt;BR /&gt;chomp;&lt;BR /&gt;@attrs=split /\t/;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I suppose a generic solution would be an attribute/value format string with recognized words for attribute and value:&lt;BR /&gt;-F "&lt;ATTR&gt;:&lt;VALUE&gt;\n"&lt;BR /&gt;-F "&lt;ATTR&gt;=&lt;VALUE&gt;:"&lt;BR /&gt;-F "&lt;VALUE&gt;\t"&lt;BR /&gt;&lt;BR /&gt;nah!&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;/VALUE&gt;&lt;/VALUE&gt;&lt;/ATTR&gt;&lt;/VALUE&gt;&lt;/ATTR&gt;</description>
      <pubDate>Fri, 17 Jun 2005 14:21:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/feedback-requested-on-output-format-for-scripting/m-p/3566176#M702597</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-06-17T14:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: Feedback requested on output format for scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/feedback-requested-on-output-format-for-scripting/m-p/3566177#M702598</link>
      <description>My vote is similar to Patrick's.  Option 2, with name/value pairs...on a seperate line.  If the name/value pairs are to be seperated by whitespace, how are we dealing with embedded whitespace as a value?&lt;BR /&gt;&lt;BR /&gt;In this case, it might be a good idea to add embedded quotes when a value contains whitespace.  But that can also create a slippery slope...because what if a value contains an escaped quote...&lt;BR /&gt;&lt;BR /&gt;Certainly it creates more food for thought.&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Jun 2005 14:55:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/feedback-requested-on-output-format-for-scripting/m-p/3566177#M702598</guid>
      <dc:creator>Tom Schroll</dc:creator>
      <dc:date>2005-06-17T14:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Feedback requested on output format for scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/feedback-requested-on-output-format-for-scripting/m-p/3566178#M702599</link>
      <description>I'll vote for option 2 where the name-value pairs are on a separate line so that its easy to read. However if the list is too long would there be a way to scroll backwards to see what the name-value pairs are?&lt;BR /&gt;&lt;BR /&gt;regards</description>
      <pubDate>Fri, 17 Jun 2005 15:11:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/feedback-requested-on-output-format-for-scripting/m-p/3566178#M702599</guid>
      <dc:creator>Sandman!</dc:creator>
      <dc:date>2005-06-17T15:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: Feedback requested on output format for scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/feedback-requested-on-output-format-for-scripting/m-p/3566179#M702600</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Thank you all for your interest in my question. Let me clarify one point, in our case, we always know the list of attribute names (they are passed as argument), and if an attribute does not exist, the whole command fails. Unless you feel this is not a good approach and you prefer to just say "not found" or some well known value if this happens.&lt;BR /&gt;&lt;BR /&gt;Your replies so far are split between option 1 (single line) and option 2 (new line), and alsop between displaying the attribute name or not.&lt;BR /&gt;&lt;BR /&gt;One solution would be to offer an option for each of those (display on single line versus display one per line; display attribute name or not).&lt;BR /&gt;&lt;BR /&gt;All your comments are valid and appreciated. Feel free to add more,&lt;BR /&gt;&lt;BR /&gt;Marie-Noelle&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 17 Jun 2005 15:53:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/feedback-requested-on-output-format-for-scripting/m-p/3566179#M702600</guid>
      <dc:creator>marie-noelle jeanson_1</dc:creator>
      <dc:date>2005-06-17T15:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: Feedback requested on output format for scripting</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/feedback-requested-on-output-format-for-scripting/m-p/3566180#M702601</link>
      <description>This thing should behave like a UNIX command -- what a concept. If you specify an incorrect attribute or argument then the command should exit with a non-zero status and write a description of the error on stderr. Conversely, if all is well, the command should exit with a zero status and write the output on stdout. There is no need to display the attribute name on the output because that is implicit in the arguments passed. I would add an optional argument that allows a user specified field separator&lt;BR /&gt;with the default set to &lt;TAB&gt;. If the field separator specified by the argument is "\n" then you could have the best of both worlds&lt;BR /&gt;because those poor lost souls whole prefer separate lines of output for each value now get it and us smart guys who want them all in one line get them like that. Moreover since the last value outputted gets a "\n" in both cases there is no additional coding required. There should be a man page and I always add a usage section requested with -u to all my scripts/programs.&lt;BR /&gt; &lt;BR /&gt;&lt;/TAB&gt;</description>
      <pubDate>Fri, 17 Jun 2005 16:10:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/feedback-requested-on-output-format-for-scripting/m-p/3566180#M702601</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2005-06-17T16:10:18Z</dc:date>
    </item>
  </channel>
</rss>

