Posted on 05-17-2013 02:50 PM
We have a loop that works fine for user jdoe or bsmith...
for u in $over500 ;
do
if [ -e /Users/"$u"/Library/Preferences/com.microsoft.Word.plist ]; then
log "com.company.plist for "$u" exists, setting backward compatibility..."
defaults write /Users/"$u"/Library/Preferences/com.microsoft.Word "14Default SaveDefault Format" "Doc97"
log "Successfully set com.microsoft.Word.plist for "$u" for backward compatibility..."
else
log "com.microsoft.Word.plist for "$u" does not exist, moving on..."
fi
done
...but it's broken for DOMAINjdoe or DOMAINsmith.
I know...what the heck are users doing logging in like that?! Dunno, the naming fiasco happened before my time. :)
In any case, we need $u to preserve the back slash...it fails for those users, logs show DOMAINjdoe and DOMAINbsmith (slash was removed), so of course it won't find/change the file. :(
How do we adjust the syntax to preserve the back slash?
It's Friday, I know everyone is tired and going home...have a great weekend!
Don
Posted on 05-18-2013 10:53 AM
Instead of using:
for u in $over500 ;
do
Try replacing that with this:
cat $over500 | while read -r useraccount
do
if [ -e /Users/"$useraccount"/Library/Preferences/com.microsoft.Word.plist ]; then
Quick explanation. The is a unix reserved character. Using while read -r allows that character to be read. (I ran into this problem a while back when processing user account names too.)
Posted on 05-18-2013 05:16 PM
Thanks Richard, I'll give this a go on Monday. If it works we'll have plenty of uses for it. :)
Posted on 05-19-2013 02:10 AM
Hey no worries!
You may have to rearchitect your loop slightly. This all works based off the fact that it's reading a long list of user info line by line. I should really have mentioned that earlier. If your variable is only being set with one piece of information, this will not work as expected.
(how can you tell i'm having a slow weekend ;) )