stderr not getting redirected to a file in Solaris shellscript
<p>I have written a shell script (on Solaris platform, if that matters), and want to redirect all the output and error of a ZFS command to a file. But when I execute the shell script, the error message is still shown on the prompt instead of redirecting to a file. Following is the shell script:</p>

<pre><code>#!/usr/bin/sh        

`zfs &lt;command&gt;` 2&gt;&amp;1 | tee file.txt   #doesn't work    
##`zfs &lt;command&gt;` &gt;&gt; output.txt 2&gt;&amp;1  #doesn't work    
</code></pre>

<p>This creates a output.txt of size 0 bytes and error message is displayed on the command prompt.</p>

<pre><code> sudo ./testShell.sh    
cannot load key for '/tank/test1': incorrect key.    
</code></pre>

<p>Any inputs, please?</p>