I'm working upon a larger script to do some finder customisation and having a problem with a dscl lookup which is quite confusing unless I'm missing something silly!
All I'm wanting this small bit to do it echo out the path to the logged in active directory users network home directory, SMBHome.
Here's the really basic script
#!/bin/bash CurrentUser=$(stat -f%Su /dev/console | awk '!/root/') ADHome=$(dscl . -read /Users/"$CurrentUser" SMBHome) echo "$ADHome"
If I run that in terminal the result it outputs is different to what happens running the exact same commands manually. See the screen shot where I've run the script and then copied the contents directly into terminal and it gives a different answer.

As you can see in the script result it misses the first and then a from the path, I assuming I'm missing something but not sure what. Any one any ideas?
