
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 10-11-2012 12:00 PM
Hey all,
I'm working on a script to rename permissions on accounts moved from Open Directory to Active Directory.
As part of the checks (while loop logic) to see if the account exists I am querying AD for the GUID of the account:
/usr/bin/dscl /Active Directory/$domain/All Domains/ -read /Users/$user GeneratedUID | /usr/bin/awk '{print $NF;}')"
This works great for accounts that do exist in that domain, but if they don't the command fails. (I might have mistyped this from my script, but the logic works ;) )
How can I capture this information into a variable, and have sterr ignore the cases where the command populating the variable fails?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 10-11-2012 12:33 PM
Add ```
2> /dev/null
``` to redirect stderr to /dev/null

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 10-11-2012 12:33 PM
Add ```
2> /dev/null
``` to redirect stderr to /dev/null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on 10-11-2012 02:14 PM
Here's one i made earlier.
accountUniqueID=`dscl . -read /Users/$1 2>dev/null | ?grep UniqueID | cut -c 11-`
