<?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: command | tee -a file in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/command-tee-a-file/m-p/5176102#M50790</link>
    <description>Thanks Guys</description>
    <pubDate>Mon, 25 May 2009 17:32:15 GMT</pubDate>
    <dc:creator>Leo The Cat</dc:creator>
    <dc:date>2009-05-25T17:32:15Z</dc:date>
    <item>
      <title>command | tee -a file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/command-tee-a-file/m-p/5176094#M50782</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;Here my command: &lt;BR /&gt;&lt;BR /&gt;java -jar example.jar | tee -a /tmp/aa.log&lt;BR /&gt;echo $?&lt;BR /&gt;&lt;BR /&gt;The problem here is that $? is always 0, of course, because the last command is tee (not my java command). How to catch the return value code for java command ?&lt;BR /&gt;&lt;BR /&gt;Bests regards&lt;BR /&gt;Den&lt;BR /&gt;</description>
      <pubDate>Tue, 19 May 2009 13:13:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/command-tee-a-file/m-p/5176094#M50782</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2009-05-19T13:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: command | tee -a file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/command-tee-a-file/m-p/5176095#M50783</link>
      <description>Maybe you should change to:&lt;BR /&gt;&lt;BR /&gt;java -jar example.jar &amp;gt;&amp;gt; /tmp/aa.log 2&amp;gt;&amp;amp;1&lt;BR /&gt;echo $?</description>
      <pubDate>Tue, 19 May 2009 13:20:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/command-tee-a-file/m-p/5176095#M50783</guid>
      <dc:creator>Ivan Ferreira</dc:creator>
      <dc:date>2009-05-19T13:20:47Z</dc:date>
    </item>
    <item>
      <title>Re: command | tee -a file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/command-tee-a-file/m-p/5176096#M50784</link>
      <description>Hi.&lt;BR /&gt;&lt;BR /&gt;No I need the tee ....&lt;BR /&gt;&lt;BR /&gt;Bests Regards&lt;BR /&gt;Den</description>
      <pubDate>Tue, 19 May 2009 13:22:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/command-tee-a-file/m-p/5176096#M50784</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2009-05-19T13:22:08Z</dc:date>
    </item>
    <item>
      <title>Re: command | tee -a file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/command-tee-a-file/m-p/5176097#M50785</link>
      <description>Then try using the PIPESTATUS variable:&lt;BR /&gt;&lt;BR /&gt;java -jar example.jar | tee -a /tmp/aa.log&lt;BR /&gt;echo $PIPESTATUS&lt;BR /&gt;&lt;BR /&gt;PIPESTATUS&lt;BR /&gt;An array variable (see Arrays below) containing a  list of  exit  status values from the processes in the most recently-executed foreground pipeline (which  may  contain only a single command).&lt;BR /&gt;</description>
      <pubDate>Tue, 19 May 2009 13:52:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/command-tee-a-file/m-p/5176097#M50785</guid>
      <dc:creator>Ivan Ferreira</dc:creator>
      <dc:date>2009-05-19T13:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: command | tee -a file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/command-tee-a-file/m-p/5176098#M50786</link>
      <description>Here are some examples I put together years ago...&lt;BR /&gt;&lt;BR /&gt;UNIX RETURN CODE PRIMER&lt;BR /&gt;[tested on Red Hat Linux using bash-2.05]&lt;BR /&gt;&lt;BR /&gt;In the examples below:&lt;BR /&gt;- it is assumed that you want to both display the output of the command (ls) and capture the exit code (a.k.a. return code value) in a variable (rc).&lt;BR /&gt;- a return code value other than "1" means the script did not work correctly.&lt;BR /&gt;&lt;BR /&gt;# Basic (correct)&lt;BR /&gt;$ ls nonexistent 2&amp;gt;&amp;amp;1; rc=$?; echo $rc&lt;BR /&gt;ls: nonexistent: No such file or directory&lt;BR /&gt;1&lt;BR /&gt;&lt;BR /&gt;# Capture return code after pipe (wrong)&lt;BR /&gt;$ ls nonexistent 2&amp;gt;&amp;amp;1 | tee -a /dev/null; rc=$?; echo $rc&lt;BR /&gt;ls: nonexistent: No such file or directory&lt;BR /&gt;0&lt;BR /&gt;&lt;BR /&gt;# Capture return code after command (wrong)&lt;BR /&gt;$ ls nonexistent 2&amp;gt;&amp;amp;1; rc=$? | tee -a /dev/null; echo $rc          &lt;BR /&gt;ls: nonexistent: No such file or directory&lt;BR /&gt;   &amp;lt;-- blank&lt;BR /&gt;&lt;BR /&gt;# Capture return code after command run in subshell (wrong)&lt;BR /&gt;$ (ls nonexistent 2&amp;gt;&amp;amp;1; rc=$?) | tee -a /dev/null; echo $rc&lt;BR /&gt;ls: nonexistent: No such file or directory&lt;BR /&gt;   &amp;lt;-- blank&lt;BR /&gt;&lt;BR /&gt;# Use I/O redirection with extra file descriptors (correct)&lt;BR /&gt;$ exec 3&amp;gt;&amp;amp;1; rc=`exec 4&amp;gt;&amp;amp;1; (ls nonexistent 2&amp;gt;&amp;amp;1; echo $? &amp;gt;&amp;amp;4) | tee -a /dev/null &amp;gt;&amp;amp;3`; exec 3&amp;gt;&amp;amp;-; echo $rc    &lt;BR /&gt;ls: nonexistent: No such file or directory&lt;BR /&gt;1&lt;BR /&gt;&lt;BR /&gt;# bash v2.0+ offers an easy-to-use PIPESTATUS array (correct)&lt;BR /&gt;$ ls nonexistent 2&amp;gt;&amp;amp;1 | tee -a /dev/null; echo ${PIPESTATUS[0]}&lt;BR /&gt;ls: nonexistent: No such file or directory&lt;BR /&gt;1&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Jared</description>
      <pubDate>Tue, 19 May 2009 22:41:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/command-tee-a-file/m-p/5176098#M50786</guid>
      <dc:creator>Jared Middleton</dc:creator>
      <dc:date>2009-05-19T22:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: command | tee -a file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/command-tee-a-file/m-p/5176099#M50787</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;If you dont want to show your output or first command then no need to give tee command.&lt;BR /&gt;tee command is showing the output of first command and send the same thing into the output file.&lt;BR /&gt;&lt;BR /&gt;Suraj</description>
      <pubDate>Wed, 20 May 2009 04:47:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/command-tee-a-file/m-p/5176099#M50787</guid>
      <dc:creator>Suraj K Sankari</dc:creator>
      <dc:date>2009-05-20T04:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: command | tee -a file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/command-tee-a-file/m-p/5176100#M50788</link>
      <description>Hi Den:&lt;BR /&gt;&lt;BR /&gt;Another way (using a temporary file):&lt;BR /&gt;&lt;BR /&gt;# (ls nofile 2&amp;gt;&amp;amp;1;echo $? &amp;gt; /tmp/rc.$$)|tee -a /dev/null;echo $(&lt;BR /&gt;Also, Den, please don't forget to evalulate the responses to some of your previous questions:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1335784" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/questionanswer.do?threadId=1335784&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Wed, 20 May 2009 11:19:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/command-tee-a-file/m-p/5176100#M50788</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-05-20T11:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: command | tee -a file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/command-tee-a-file/m-p/5176101#M50789</link>
      <description>If you want to avoid temp files and bash-specific variables....&lt;BR /&gt;&lt;BR /&gt;rc=$({ { your-command ; echo $? 1&amp;gt;&amp;amp;3 ;} | tee -a output.txt 1&amp;gt;&amp;amp;2 ;} 3&amp;gt;&amp;amp;1) 2&amp;gt;&amp;amp;1&lt;BR /&gt;echo "rc=$rc"</description>
      <pubDate>Wed, 20 May 2009 18:30:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/command-tee-a-file/m-p/5176101#M50789</guid>
      <dc:creator>Heironimus</dc:creator>
      <dc:date>2009-05-20T18:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: command | tee -a file</title>
      <link>https://community.hpe.com/t5/operating-system-linux/command-tee-a-file/m-p/5176102#M50790</link>
      <description>Thanks Guys</description>
      <pubDate>Mon, 25 May 2009 17:32:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/command-tee-a-file/m-p/5176102#M50790</guid>
      <dc:creator>Leo The Cat</dc:creator>
      <dc:date>2009-05-25T17:32:15Z</dc:date>
    </item>
  </channel>
</rss>

