MacOS – Help converting Apple Script to Shell Script

applescriptcommand linemacosterminal

This Apple Script works great to mount the logged in Active Directory users network homedrive as a mounted network drive but we currently have it running as an App at login via "Login Items".

Instead I'd like to write this as a shell script so I can push it via Profile Manager as a login script since we are now succesfully running a few tasks off of a login script from PM.

Here is the AppleScript:

set username to do shell script "whoami"

set homepath to do shell script "dscl '/Active Directory/CAMPUS/All Domains/' -read /Users/" & username & " | grep SMBHome: | cut -c 10- | sed 's/\\\\/\\//g' "

tell application "Finder"

    try
        mount volume "SMB:" & homepath
    end try
end tell

Thank you for your help!

Best Answer

Below is a starting point.

username=`whoami`
homepath=`dscl '/Active Directory/CAMPUS/All Domains/' -read /Users/$username |grep SMBHome: | cut -c 10- | sed 's/\\\\/\\//g'`

mount_smbfs $homepath <mount_point>

I'm not really sure of the mount syntax. This answer may help with mount syntax.