Posted on 04-08-2022 09:36 AM
Hi there,
I'm trying to create an AppleScript to mount a network home drive for logged in users. Our current Python Script is dead with 12.3.
I'd like to map the drive for the current user in the script below. Instead of jane.doe, I tried using $3, $User, ~ and a bunch of brackets. How can I replace jane.doe with the current signed in user?
tell application "Finder"
open location "smb://example.com/networkshares/Home%20Directories/jane.doe"
end tell
Solved! Go to Solution.
Posted on 04-08-2022 09:54 AM
#!/bin/bash
currentuser=$(/usr/bin/who | awk '/console/{ print $1 }')
/usr/bin/osascript > /dev/null << EOT
tell application "Finder"
activate
mount volume "smb://example.com/networkshares/Home%20Directories/${currentuser}/"
end tell
EOT
Posted on 04-08-2022 12:17 PM
This is the basic idea
set userName to do shell script "whoami"
mount volume "smb://example.com/networkshares/Home%20Directories/" & userName
Posted on 04-08-2022 09:54 AM
#!/bin/bash
currentuser=$(/usr/bin/who | awk '/console/{ print $1 }')
/usr/bin/osascript > /dev/null << EOT
tell application "Finder"
activate
mount volume "smb://example.com/networkshares/Home%20Directories/${currentuser}/"
end tell
EOT
Posted on 04-08-2022 10:48 AM
Yeah, that worked. I'm trying to embed this in an AppleScript so I can push it out as an App. Do you know how to embed this bash script into AppleScript?
I'm trying the "do shell script" command.
Posted on 04-08-2022 12:17 PM
This is the basic idea
set userName to do shell script "whoami"
mount volume "smb://example.com/networkshares/Home%20Directories/" & userName
Posted on 04-08-2022 12:26 PM
Woah, that worked! Thanks a lot @YanW!
This will give me 2 options to let users open this in Self Service and download the AppleScript Apps to their Dock and open. Very cool.