<?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: Capture output of successful command in a shell. in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/capture-output-of-successful-command-in-a-shell/m-p/2910339#M719787</link>
    <description>Hi&lt;BR /&gt;&lt;BR /&gt;Try this&lt;BR /&gt;#(sleep 10 ;echo $? &amp;gt; output.txt ) &amp;amp;&lt;BR /&gt;&lt;BR /&gt;Chris</description>
    <pubDate>Fri, 21 Feb 2003 13:31:57 GMT</pubDate>
    <dc:creator>Christian Gebhardt</dc:creator>
    <dc:date>2003-02-21T13:31:57Z</dc:date>
    <item>
      <title>Capture output of successful command in a shell.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/capture-output-of-successful-command-in-a-shell/m-p/2910337#M719785</link>
      <description>Hello All,&lt;BR /&gt;&lt;BR /&gt;How to get the results of a sucessfull command into a variable? &lt;BR /&gt;&lt;BR /&gt;I know the way to get the output of an "unsuccessful" command into a variable, from the discussion today initiated by Sean on this forum.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;For Example,&lt;BR /&gt;I want to grab the output of sleep when it is sucessful, to get the process id of the process:&lt;BR /&gt;&lt;BR /&gt;I execute the following command:&lt;BR /&gt;$ sleep 10 &amp;amp;&lt;BR /&gt;[1]     13482&lt;BR /&gt;&lt;BR /&gt;I want to capture the output containing the process id.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Shashi</description>
      <pubDate>Fri, 21 Feb 2003 13:19:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/capture-output-of-successful-command-in-a-shell/m-p/2910337#M719785</guid>
      <dc:creator>Shashibhushan Gokhale</dc:creator>
      <dc:date>2003-02-21T13:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: Capture output of successful command in a shell.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/capture-output-of-successful-command-in-a-shell/m-p/2910338#M719786</link>
      <description>You can't 'capture' that output.&lt;BR /&gt;&lt;BR /&gt;However, the process id of the last background command invoked by the shell (13482) in your example is held in the $! variable.&lt;BR /&gt;&lt;BR /&gt;Thus:&lt;BR /&gt;sleep 10&amp;amp;&lt;BR /&gt;CHILD=${!}&lt;BR /&gt;&lt;BR /&gt;$CHILD will contain the relevant PID.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;John</description>
      <pubDate>Fri, 21 Feb 2003 13:25:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/capture-output-of-successful-command-in-a-shell/m-p/2910338#M719786</guid>
      <dc:creator>John Palmer</dc:creator>
      <dc:date>2003-02-21T13:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: Capture output of successful command in a shell.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/capture-output-of-successful-command-in-a-shell/m-p/2910339#M719787</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Try this&lt;BR /&gt;#(sleep 10 ;echo $? &amp;gt; output.txt ) &amp;amp;&lt;BR /&gt;&lt;BR /&gt;Chris</description>
      <pubDate>Fri, 21 Feb 2003 13:31:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/capture-output-of-successful-command-in-a-shell/m-p/2910339#M719787</guid>
      <dc:creator>Christian Gebhardt</dc:creator>
      <dc:date>2003-02-21T13:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: Capture output of successful command in a shell.</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/capture-output-of-successful-command-in-a-shell/m-p/2910340#M719788</link>
      <description>Hi Shashi,&lt;BR /&gt;&lt;BR /&gt;I know it doesn't directly put the output into a variable, but you could use the script command:&lt;BR /&gt;&lt;BR /&gt;script /tmp/output.txt&lt;BR /&gt;sleep 1 &amp;amp;&lt;BR /&gt;Ctrl-D&lt;BR /&gt;&lt;BR /&gt;cat /tmp/output.txt&lt;BR /&gt;Script started on Fri Feb 21 14:16:14 2003&lt;BR /&gt;# sleep 1 &amp;amp;&lt;BR /&gt;[1]     18447&lt;BR /&gt;ln4p2714-64 #&lt;BR /&gt;&lt;BR /&gt;script done on Fri Feb 21 14:16:21 2003&lt;BR /&gt;&lt;BR /&gt;rgds, Robin</description>
      <pubDate>Fri, 21 Feb 2003 14:17:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/capture-output-of-successful-command-in-a-shell/m-p/2910340#M719788</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2003-02-21T14:17:54Z</dc:date>
    </item>
  </channel>
</rss>

