result returns just new line \n not whats printed after command is run Ultimately I'm trying to catch some errors that are popping up but aren't getting returned. 

Here's the command I'm trying to run. 

/usr/bin/dscl . -change /Users/admin NFSHomeDirectory /Users/admin /var/admin


when it runs successfully it returns \n
when it comes up with an error I get \n and 

&lt;main&gt; attribute status: eDSAttributeNotFound
&lt;dscl_cmd&gt; DS Error: -13134 (eDSAttributeNotFound)


I know why I'm getting the error and I'm actually making it happen intentionally so that I can (hopefully) get terminal to write the next two lines out to a file or (eventually) send it using CURL to another computer. 

So when I run the command with either > tomytextfile.txt it writes and empty file or using my POST request like so 

echo "result=`/usr/bin/dscl . -change /Users/admin NFSHomeDirectory /Users/admin /var/admin`" | curl --data-urlencode result@- http://172.16.26.251:8080/script


I get this as the response on the server where I'm sending the curl POST request. 

{ result: 'result=\n' }


If anyone has any ideas, I'd be super grateful.
You could try replacing &gt; tomytextfile.txt with &gt; tomytextfile.txt 2&gt;&amp;1.

Similarly, you could use what is shown below. 

echo "result=`/usr/bin/dscl . -change /Users/admin NFSHomeDirectory /Users/admin /var/admin 2&gt;&amp;1`" | curl --data-urlencode result@- http://172.16.26.251:8080/script


Basically, 2&gt;&amp;1 redirects error output to regular output.