• 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: will this code test if a user is in a group?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: will this code test if a user is in a group?


  • Subject: Re: will this code test if a user is in a group?
  • From: Axel Luttgens <email@hidden>
  • Date: Sat, 12 Jul 2008 10:18:41 +0200

Le 11 juil. 08 à 18:30, email@hidden a écrit :

set theScript to "/usr/bin/id"
set userInfo to do shell script theScript

if (userInfo contains "Engineering") then
  mount volume "afp://server.ip/Engineering/"

else if (userInfo contains "Engineering") then
  mount volume "afp://server.ip/Graphics_Design/"
  mount volume "afp://server.ip/ClipArt/"

end if

Hello Charles,

Philip already pointed out a likely typo in your if/then/else construct (perhaps did you mean, for example, "Graphics" instead of "Engineering" in the else part?).

That said, I would tend to write:
set theScript to "/usr/bin/id -Gn"
That way, one gets a string of space-separated group names, thus reducing the risk of having other irrelevant pieces of text that could match as well.


Moreover, this one might prove more correct:
set userInfo to words of (do shell script theScript)
That way, one gets a list of group names.
The reason being that:
someString contains someChunk
checks for the occurrence of someChunk *as a substring* of someString, while:
someList contains someChunk
checks whether someChunk appears *as an item* of someList; again, the latter should help to avoid incorrect matches.


Finally, should your script be for Leopard only, perhaps could you have a look at the "dsmemberutil" tool instead of the "id" tool.

HTH,
Axel _______________________________________________
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: will this code test if a user is in a group?
      • From: Axel Luttgens <email@hidden>
References: 
 >will this code test if a user is in a group? (From: email@hidden)

  • Prev by Date: Invalid key form errors with Keynote slides
  • Next by Date: Re: Invalid key form errors with Keynote slides
  • Previous by thread: Re: will this code test if a user is in a group?
  • Next by thread: Re: will this code test if a user is in a group?
  • Index(es):
    • Date
    • Thread