0

I am trying to write a small script to launch when user logs on. I have searched and got the script to work but unable to run at log on with .plist

We have active directory setup. When the user logs in using their credentials the script manually works once executed

tell application "finder"
    set MyName to do shell script "whoami"
    mount volume "smb://server/folder/" & MyName
end tell

or

set MyName to do shell script "whoami"
mount volume "smb://server/folder/" & MyName

and saved it as .scpt both manually works

Or i need to use it this way

tell application "Terminal"
    set MyName to do shell script "whoami"
    mount volume "smb://server/folder/" & MyName
end tell

save it as .sh

Now the plist is saved in /Library/LaunchAgents:

<plist version="1.0">

<dict>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>com.script</string>
    <key>ProgramArguments</key>
    <array>
       <string>/Users/Shared/SCRIPT.sh</string>
    </array>
</dict>

</plist>

and do the following command

launchctl load /Library/LaunchAgents/com.script.plist

It does not work. Cant get the drive to auto-mount during logon

Please help. I am not a programmer so please be specific.

Thank you, Chris

2
  • Hey, I cleaned up some of your script formatting for this site. It seemed like some characters were cut off, so I tried to replace them to create a valid PLIST, but double-check that it accurately reflects what was actually in the file. Also, are you using Linux or OSX? They're two different operating systems as far as this is concerned, and will have different answers (but you tagged for both). Jul 25, 2014 at 20:40
  • I'm using osx 10.9 mavericks....in the post i removed the > because it wouldn't show all the codes...thank you...looks much better
    – Chris
    Jul 25, 2014 at 21:45

1 Answer 1

0

Your script is an applescript, not a shell script, so you can't execute it directly. I think it'd work to have the ossascript command interpret it:

<array>
    <string>/usr/bin/osascript</string>
    <string>/Users/Shared/SCRIPT.sh</string>
</array>

(& please use a more appropriate file extension than ".sh")

BTW, I'm pretty sure you want KeepAlive set to <false/> -- with it set to <true/>, your script will be rerun continuously rather than just once.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .