<?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: Tar with  Shell Scripts in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859789#M396221</link>
    <description>The problem is the order in which stdout and stderr is redirected.&lt;BR /&gt;&lt;BR /&gt;Try this&lt;BR /&gt;&lt;BR /&gt;/bin/tar tf /dev/rmt/0m &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;This should work.&lt;BR /&gt;</description>
    <pubDate>Tue, 07 Sep 2004 11:52:10 GMT</pubDate>
    <dc:creator>Sundar_7</dc:creator>
    <dc:date>2004-09-07T11:52:10Z</dc:date>
    <item>
      <title>Tar with  Shell Scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859785#M396217</link>
      <description>I am trying to verify ignite tapes after writing with a ksh script and email the results, but I cannot manage to send the read of the tar archive on the tape to /dev/null so that it does not appear in the out going email.&lt;BR /&gt;&lt;BR /&gt;Everything else is working, I know the ignite boot blocks are good, etc, it's just the tar archive read back that is the problem: too verboose. A pain to read at best, and usually gets trunciated by the MS exchange system anyway.  Unfortunatly the read-back of the boot block is then lost also.&lt;BR /&gt;&lt;BR /&gt;The vfy cmd used is:&lt;BR /&gt;  /bin/tar tf /dev/rmt/0m 2&amp;gt;&amp;amp;1 &amp;gt; /dev/null&lt;BR /&gt;&lt;BR /&gt;If I recall correctly from the very distant past, tar does not send the output to standard err under this situation, but how can I trap it?  Any suggestions?&lt;BR /&gt;&lt;BR /&gt;Thanks Rt.</description>
      <pubDate>Tue, 07 Sep 2004 10:07:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859785#M396217</guid>
      <dc:creator>Robert True</dc:creator>
      <dc:date>2004-09-07T10:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: Tar with  Shell Scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859786#M396218</link>
      <description>&lt;BR /&gt;To get error messages just PRETEND to restore a BOGUS file:&lt;BR /&gt;&lt;BR /&gt;tar -xvf /dev/rmt/0m crazymanfilename 2&amp;gt;&amp;amp;1 | uuencode errors.txt | mailx -m -s "tar er&lt;BR /&gt;rors" youremail@yourdomain.com&lt;BR /&gt;&lt;BR /&gt;You can get errors like:&lt;BR /&gt; tar: cannot open nxewtest.tar&lt;BR /&gt;or&lt;BR /&gt; Tar: error! blocksize changed&lt;BR /&gt;or whatever&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Tue, 07 Sep 2004 10:35:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859786#M396218</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2004-09-07T10:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: Tar with  Shell Scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859787#M396219</link>
      <description>I would suggest on a spot with some free space&lt;BR /&gt;&lt;BR /&gt;tar tf /dev/rmt/0m &amp;gt; testfile.txt&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Tue, 07 Sep 2004 10:38:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859787#M396219</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2004-09-07T10:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: Tar with  Shell Scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859788#M396220</link>
      <description>ok,&lt;BR /&gt;2 possibilities :&lt;BR /&gt;1) after the tar command, verify the return status of the command (under ksh) :&lt;BR /&gt;/bin/tar tf /dev/rmt/0m 2&amp;gt;&amp;amp;1 &amp;gt; /dev/null&lt;BR /&gt;STATUS=$?&lt;BR /&gt;if [ $STATUS -ne 0 ]&lt;BR /&gt;then&lt;BR /&gt; echo "Problem with tar on `hostname`" |mailx -m -s "pbl with tar" your_name@your_address&lt;BR /&gt;fi&lt;BR /&gt;tar only retuns 0 if everything is ok ! I test with modifying an tar file and it returns : 3&lt;BR /&gt;&lt;BR /&gt;2) modify your command line to extract any error :&lt;BR /&gt;/bin/tar tf /dev/rmt/0m &amp;gt; /dev/null 2&amp;gt; error_tar.txt&lt;BR /&gt;if [ -s error_tar.txt ]&lt;BR /&gt;then&lt;BR /&gt; echo "Problem with tar on `hostname`" |mailx -m -s "pbl with tar" your_name@your_address&lt;BR /&gt;fi&lt;BR /&gt;With my previous manually modification, error_tar.txt contains : &lt;BR /&gt;Tar: tape blocksize error&lt;BR /&gt;&lt;BR /&gt;Hope this helps you !&lt;BR /&gt;&lt;BR /&gt;Olivier.</description>
      <pubDate>Tue, 07 Sep 2004 10:40:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859788#M396220</guid>
      <dc:creator>Olivier Decorse</dc:creator>
      <dc:date>2004-09-07T10:40:03Z</dc:date>
    </item>
    <item>
      <title>Re: Tar with  Shell Scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859789#M396221</link>
      <description>The problem is the order in which stdout and stderr is redirected.&lt;BR /&gt;&lt;BR /&gt;Try this&lt;BR /&gt;&lt;BR /&gt;/bin/tar tf /dev/rmt/0m &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;This should work.&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Sep 2004 11:52:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859789#M396221</guid>
      <dc:creator>Sundar_7</dc:creator>
      <dc:date>2004-09-07T11:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Tar with  Shell Scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859790#M396222</link>
      <description>You command should read &lt;BR /&gt; /bin/tar tf /dev/rmt/0m &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;Or maybe even ..../dev/rmt/0mn .... for no-rewind device.&lt;BR /&gt;You may also send the output to a file, and send a line count (wc -l) in an email?&lt;BR /&gt;And the return code of the tar command too.&lt;BR /&gt;&lt;BR /&gt;JP.&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Sep 2004 12:07:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859790#M396222</guid>
      <dc:creator>Jeroen Peereboom</dc:creator>
      <dc:date>2004-09-07T12:07:34Z</dc:date>
    </item>
    <item>
      <title>Re: Tar with  Shell Scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859791#M396223</link>
      <description>Just to explain why "2&amp;gt;&amp;amp;1 &amp;gt; /dev/null" and "&amp;gt; /dev/null 2&amp;gt;&amp;amp;1" are very different, this is what is happening: The shell processes file redirection left to right so 2&amp;gt;&amp;amp;1 &amp;gt;/dev/null says: take whatever stdin (descriptor #1) is and set stdout to the same fd. Then &amp;gt;/dev/null changes stdout to /dev/null but stderr is still going to whatever stderr was in the beginning. The effect (assuming default conditions) is that stdout goes to /dev/null and stderr goes to the terminal display.&lt;BR /&gt; &lt;BR /&gt;In the second case, &amp;gt;/devnull changes stdout, then 2&amp;gt;&amp;amp;1 change stderr to match the current state of stsout, which is /dev/null. Note that there will be no output at all which not what is desired. I would redirect stderr into your email message and let stdout go to your email. That way, you'll get the tar error messages but the table of contents will be sent to /dev/null.&lt;BR /&gt; &lt;BR /&gt;One other note: /bin has been gone for more than a decade. Just like Solaris and other SysV Unices, the v.4 filesystem layout has obsoleted /bin and /lib. They are now /usr/bin and /usr/lib. The reason things seem to work OK is through the use of transition links:&lt;BR /&gt; &lt;BR /&gt;ll -d /bin /lib&lt;BR /&gt;lr-xr-xr-t   1 root       sys              8 Oct 29  2003 /bin@ -&amp;gt; /usr/bin&lt;BR /&gt;lr-xr-xr-t   1 root       sys              8 Oct 29  2003 /lib@ -&amp;gt; /usr/lib&lt;BR /&gt; &lt;BR /&gt;These are "transition" links (hint, hint) and may not be installed in future versions of HP-UX.</description>
      <pubDate>Tue, 07 Sep 2004 13:28:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859791#M396223</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2004-09-07T13:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: Tar with  Shell Scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859792#M396224</link>
      <description>============================================2&amp;gt;&amp;amp;1 &amp;gt;/dev/null says: take whatever stdin (descriptor #1) is and set stdout to the same fd. Then &amp;gt;/dev/null changes stdout to /dev/null but stderr is still going to whatever stderr was in the beginning&lt;BR /&gt;============================================&lt;BR /&gt;&lt;BR /&gt;With all due respect, I believe Bill intended to say this :-)&lt;BR /&gt;&lt;BR /&gt;============================================&lt;BR /&gt;2&amp;gt;&amp;amp;1 &amp;gt;/dev/null says: take whatever stdout (descriptor #1) is and set stderr to the same fd.Then &amp;gt;/dev/null changes stdout to /dev/null but stderr is still going to whatever stdout was in the beginning&lt;BR /&gt;============================================&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Sep 2004 16:28:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859792#M396224</guid>
      <dc:creator>Sundar_7</dc:creator>
      <dc:date>2004-09-07T16:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: Tar with  Shell Scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859793#M396225</link>
      <description>Thanks Sundar. Redirection based on redirection really needs some arrows and drawings. ;-}</description>
      <pubDate>Tue, 07 Sep 2004 22:04:16 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859793#M396225</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2004-09-07T22:04:16Z</dc:date>
    </item>
    <item>
      <title>Re: Tar with  Shell Scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859794#M396226</link>
      <description>Thanks for all the comments, esp. the hints on redirection, but the tar command uses fd3 to output the list of files and because of the nesting of the shell scripts being used, I have not been able to trap it yet.  I am Closing the thread as you ave gotten me on the  right track, and I do not currently have time to work on it further.&lt;BR /&gt;&lt;BR /&gt;Thanks again!&lt;BR /&gt;&lt;BR /&gt;Rt.</description>
      <pubDate>Wed, 29 Sep 2004 10:18:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859794#M396226</guid>
      <dc:creator>Robert True</dc:creator>
      <dc:date>2004-09-29T10:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: Tar with  Shell Scripts</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859795#M396227</link>
      <description>See my last posting.&lt;BR /&gt;&lt;BR /&gt;Rt.</description>
      <pubDate>Wed, 29 Sep 2004 10:19:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/tar-with-shell-scripts/m-p/4859795#M396227</guid>
      <dc:creator>Robert True</dc:creator>
      <dc:date>2004-09-29T10:19:40Z</dc:date>
    </item>
  </channel>
</rss>

