• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Has anyone created a script for AD 2008 home and shares in OS X.5/6?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Has anyone created a script for AD 2008 home and shares in OS X.5/6?


  • Subject: Re: Has anyone created a script for AD 2008 home and shares in OS X.5/6?
  • From: "Mark J. Reed" <email@hidden>
  • Date: Tue, 20 Jul 2010 13:43:35 -0400

I'm confused by the use of AppleScript at all here.  If it's just a
bunch of 'do shell script' statements, it's more efficient to just
write a shell script and run that. At the very least, you can get rid
of the Finder tell block, since you aren't using the Finder here, and
the current_os variable, which is unused.

The shell script below (untested) should do the trick by itself.
Things to note:

1. If you want the home directory of the user running a script, you
can just use ~ or $HOME.  It's probably /Users/$username, but not
always.   (This removes the need for the current_muser variable.)

2. Use mkdir -p to create a directory that might already exist,
without complaining if it does.  Similarly, use rm -f to remove
without complaint a file that might already be absent.

3. The mkdir of /Volumes/UNCHome and the symlink to ~/Desktop/Home
were the same whether the user is a student or not, so I took them out
of the conditional.

4. "the foo{1,2,3}bar" syntax is just shorthand for "foo1bar foo2bar
foo3bar": an easy way to type a list of strings that have some
commonality.

5. I split the mount_smbfs commands across two lines for clarity,
using the backslash as a line-continuation character (which must be
the last thing on the line, no trailing whitespace).  You can also
just make them one long line.

6. Save the script in a file, say "mount_uni_shares.sh", and make it
executable (chmod +x mount_uni_shares.sh) and then you can run it by
just typing its name at a shell prompt (or running it from AS with 'do
shell script "/path/to/mount_uni_shares.sh", which is moderately less
silly than firing up a new shell for each line of the script).


#!/bin/bash
#
#      This script tests the group of the user and the version of
#      of OS X then mounts the proper shared volumes and creates
#      an alias on the desktop. It also tests to see if facultyserver exists and
#      if it does not it will not run the mount part of the script

let j=4 # Number of times to ping the server

for (( i=0; i<j; ++i )); do
    # exit the loop if ping is successful
    ping -c 1 facultyserver && break
done

# If all pings failed, exit quietly
if (( i==j )); then
    exit 128
fi

current_user="$(whoami | sed -e 's/ / g')"
current_group="$(id)"

set -o braceexpand
rm -f ~/Desktop/{Home,{Student,Faculty}Share}

mkdir -p /Volumes/UNCHome
ln -s /Volumes/UNCHome ~/Desktop/Home

case "$current_group" in
    *gStudents*)
        # home directory mounting and alias for students clients
        mount_smbfs -N "//studentserver.pcsd.monroe.edu/$current_user\$" \
                                  /Volumes/UNCHome
        ;;
    *)
        # faculty and staff login items
        mount_smbfs -N "//facultyserver.pcsd.monroe.edu/$current_user\$" \
                                  /Volumes/UNCHome
        mkdir -p /Volumes/FacultyShare
        mount_smbfs -N //facultyserver.monroe.edu/shared \
                                 /Volumes/FacultyShare
        ln -s /Volumes/FacultyShare ~/Desktop/FacultyShare
        ;;
esac


# student, faculty and staff login items

mkdir -p /Volumes/StudentShare
mount_smbfs -N //studentserver.pcsd.monroe.edu/shared \
                         /Volumes/StudentShare
ln -s /Volumes/StudentShare ~/Desktop/StudentShare

On Tue, Jul 20, 2010 at 9:14 AM, Emmanuel LEVY <email@hidden> wrote:
> I'm not sure I understand all of your issues - starting with the fact that I
> don't see where the Gregorian calendar enter in - but if this can help, a
> line like:
>
>    do shell script ("ln -s /Volumes/FacultyShare /Users/'" & current_muser &
> "'/Desktop/FacultyShare")
>
> should absolutely be avoided, as this will make uncontrolable situations
> when current_muser includes a space. Do use "quoted form" around paths, like
> in :
>
> -- untested
>    do shell script ("ln -s " & quote form of ("/Volumes/FacultyShare
> /Users/'" & current_muser & "'/Desktop/FacultyShare") )
>
> Emmanuel
>
>
>> Hello,
>>
>> I am not very adept to scripting, but recently the AD techs changed many
>> things on me, especially the paths to student home folders and shares in AD.
>>
>> I used to have a script that worked, being we were all 10.4/10.5 and had
>> the paths set up to work, being 10.4 was not able to see as deep into
>> layers.
>>
>> As shown:
>>
>> (*
>>
>>      This script tests the group of the user and the version of
>>
>>      of OS X then mounts the proper shared volumes and creates
>>
>>      an alias on the desktop. It also tests to see if facultyserver exists
>> and
>>
>>      if it does not it will not run the mount part of the script
>>
>> *)
>>
>>
>>
>> set j to 4 --Number of times to ping the server
>>
>> repeat with i from 0 to j
>>
>>         if i < j then
>>
>>                   try
>>
>>                            do shell script "ping -c 1 facultyserver"
>>
>>                            exit repeat --If the ping was successful, jump
>> to the end of the repeat
>>
>>                   on error
>>
>>                            if i = (j - 1) then
>>
>>                                     error number -128 --Exits the script
>> quietly
>>
>>                            end if
>>
>>                   end try
>>
>>         end if
>>
>> end repeat
>>
>>
>>
>>
>>
>>
>> set current_user to (do shell script "whoami | sed 's/ / /g'") as text
>>
>> set current_muser to (do shell script "whoami") as text
>>
>> set current_os to (do shell script "uname -r") as text
>>
>> set current_group to (do shell script "id") as text
>>
>>
>>
>> (* clear old settings *)
>>
>> tell application "Finder"
>>
>>         try
>>
>>                   do shell script ("rm /Users/'" & current_muser &
>> "'/Desktop/Home")
>>
>>         end try
>>
>>         try
>>
>>                   do shell script ("rm /Users/'" & current_muser &
>> "'/Desktop/StudentShare")
>>
>>         end try
>>
>>         try
>>
>>                   do shell script ("rm /Users/'" & current_muser &
>> "'/Desktop/FacultyShare")
>>
>>         end try
>>
>>
>>
>>         (* mounts and aliases *)
>>
>>         try
>>
>>                   if current_group does not contain "gStudents" then
>>
>>                            (* faculty and staff login items *)
>>
>>                            (* home directory mounting and alias for 10.4
>> faculty clients *)
>>
>>                            do shell script ("mkdir /Volumes/UNCHome")
>>
>>                            do shell script ("mount_smbfs -N
>> //facultyserver.pcsd.monroe.edu/" & current_user & "$ /Volumes/UNCHome")
>>
>>                            do shell script ("ln -s /Volumes/UNCHome
>> /Users/'" & current_muser & "'/Desktop/Home")
>>
>>
>>
>>
>>
>>                            (* facultyserver shared mounting for faculty
>> and staff *)
>>
>>                            do shell script ("mkdir /Volumes/FacultyShare")
>>
>>                            do shell script ("mount_smbfs -N
>> //facultyserver.monroe.edu/shared /Volumes/FacultyShare")
>>
>>                            do shell script ("ln -s /Volumes/FacultyShare
>> /Users/'" & current_muser & "'/Desktop/FacultyShare")
>>
>>                   else
>>
>>                            (* home directory mounting and alias for 10.4
>> students clients *)
>>
>>                            do shell script ("mkdir /Volumes/UNCHome")
>>
>>                            do shell script ("mount_smbfs -N
>> //studentserver.pcsd.monroe.edu/" & current_user & "$ /Volumes/UNCHome")
>>
>>                            do shell script ("ln -s /Volumes/UNCHome
>> /Users/'" & current_muser & "'/Desktop/Home")
>>
>>                   end if
>>
>>                   (* student, faculty and staff login items *)
>>
>>
>>
>>                   (* studentserver mounting for faculty, staff and
>> students *)
>>
>>                   do shell script ("mkdir /Volumes/StudentShare")
>>
>>                   do shell script ("mount_smbfs -N
>> //studentserver.pcsd.monroe.edu/shared /Volumes/StudentShare")
>>
>>                   do shell script ("ln -s /Volumes/StudentShare /Users/'"
>> & current_muser & "'/Desktop/StudentShare")
>>
>>
>> The student pathway now includes a grad year, so path is now different.
>>  (The example Leo, is my cat...so no student info was given out)
>>
>> For student Leo Staub I have the following for home and share:
>>
>> /Volumes/Home/2017/Staub\ Leo
>>
>> /Volumes/Shared
>>
>> I do not believe the path for the "Shared" has changed, aside from the
>> home path of the student themselves.  However, I think the "\ " slash +
>> space is part of the issue.
>>
>> In all our findings, we see many people having problems with specifying
>> paths with (escapes) getting  , etc.  Found some resolve to using two
>> \\...but still having problems.
>>
>> Being, when a user logs in, the dock has a link to their home....is there
>> a scripted way or a way to "show" the user's home on the desktop?
>>       The main reason for this...saving a file in MS Word...if link shows
>> on desktop to home...can save as to desktop/home/2017/Staub_Leo to save a
>> file to their network H drive.
>>
>> If anyone knows how to accomplish this or if you know of great
>> resources...that have integrated AD 2008, that may have already come up with
>> fix or option...that is also great.  Thanks so much!
>>
>> Jerry Staub  ACSP, MCP
>> Monroe #1 BOCES Sr. Network Technician
>> email@hidden
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> AppleScript-Users mailing list      (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> Archives: http://lists.apple.com/archives/applescript-users
>>
>> This email sent to email@hidden
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> AppleScript-Users mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
> Archives: http://lists.apple.com/archives/applescript-users
>
> This email sent to email@hidden
>



--
Mark J. Reed <email@hidden>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Has anyone created a script for AD 2008 home and shares in OS X.5/6?
      • From: Emmanuel LEVY <email@hidden>
References: 
 >Has anyone created a script for AD 2008 home and shares in OS X.5/6? (From: email@hidden)
 >Re: Has anyone created a script for AD 2008 home and shares in OS X.5/6? (From: Emmanuel LEVY <email@hidden>)

  • Prev by Date: Re. Floating On Screen Clock
  • Next by Date: Re: Re. Floating On Screen Clock
  • Previous by thread: Re: Has anyone created a script for AD 2008 home and shares in OS X.5/6?
  • Next by thread: Re: Has anyone created a script for AD 2008 home and shares in OS X.5/6?
  • Index(es):
    • Date
    • Thread