I’m trying to make a login applescript that work out if the current user is a member of an AD group.
I can get the username, but need to prepend it with "domain"
I can do it with a shell script like this
export user=$(whoami) – get the username
domain_user=$our_domain_name’'$user – prepend the domain and slash
dsmemberutil flushcache – flush the cache
export answer=“$(dsmemberutil checkmembership -U $domain_user -G group_name)”
if [[ “$answer” == not ]]
then
do some stuff here
fi
Ive tried putting this into applescript:
try
set user to do shell script "whoami"
set TheCommand to "dsmemberutil checkmembership -U " & "our_domain_name\\" & user & " -G group_name"
do shell script "dsmemberutil flushcache"
try
set Answer to do shell script TheCommand
end try
end try
But the shell command does not see the . how can i get around the escape charater problem? The double slash does not work…
I am sorry for having forgotten all about this in the heat.
The script below will produce one slash, as you see I use both a double slash, and quoted form.
I have to do that, since it is an escape character within applescript itself, not only in the do shell script command. This works for one slash, I can’t tell you how you would produce two slashes in a row!
set a to quoted form of "\\"
do shell script "echo " & a & ">~/Desktop/ch.test"