0

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

<main> attribute status: eDSAttributeNotFound
<dscl_cmd> 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.

1

You could try replacing > tomytextfile.txt with > tomytextfile.txt 2>&1.

Similarly, you could use what is shown below.

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

Basically, 2>&1 redirects error output to regular output.

  • Yup, That worked like a charm. Thank you very much for your help. – TheCainSauce May 8 at 12:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .