• 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
shell script to change permissions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

shell script to change permissions


  • Subject: shell script to change permissions
  • From: Jim Weisbin <email@hidden>
  • Date: Wed, 30 Jul 2008 18:14:26 -0400

I'm probably re-inventing the wheel here, but I wrote this because of difficulties with POSIX permissions using Leopard server - seems that files copied from a client to the server lose their group permission to write and become read-only. However, if you copy them to your desktop first and change the group and everyone to read-write, then copy them back to the server, they have the correct permissions for that share point. So this takes a folder and makes it's contents entirely read-write for everyone. The folder MUST be on the user's desktop (don't want to screw up permissions on the rest of the system!), and root user must be enabled. My question is about the cd command in the shell script. Theoretically, if I cd to that folder, I can just do "chown -R *" instead of "chown -R " & path_to_folder

But that scares me - how do I know I really cd'd there?  If not, the chown -R * could be very very bad!

on open f
try
process_this(f)
end try
end open


on process_this(f)
-- set f to choose folder with prompt "Choose a folder or volume:"
set the item_info to info for f
if folder of the item_info is false then
beep
display dialog "It must be a folder, not a file!" buttons {"Oh Crap!"} default button 1
else


set f1 to quoted form of POSIX path of f
set userHome to (short user name of (system info)) as string
set f2 to userHome & "/Desktop"
if f1 contains f2 then
set my_pass to text returned of (display dialog "Enter password for " & ¬
quoted form of ¬
"Root user of this computer" with title ¬
"Fix Folder Permissions" with icon stop ¬
default answer ¬
"" buttons {"Continue…"} ¬
default button 1 ¬
with hidden answer)
try
do shell script "cd  " & f1 & "; chown -R " & userHome & " " & f1 & "; chgrp -R staff " & f1 & "; chmod -R ugo=rwx " & f1 user name "root" password my_pass with administrator privileges
on error
beep
display dialog "Invalid password!" buttons {"Oh Crap!"} default button 1
end try
else
beep
display dialog "Folder must be on your desktop!" buttons {"Oh Crap!"} default button 1
end if
end if
end process_this

Jim Weisbin | C.T.O. | human | 138 Fifth Avenue | 3rd Floor | New York, NY | 10011 | + (212) 352-0211 | + (917) 375-2272
Los Angeles Office | 2046 Broadway | Santa Monica, CA | 90404 | + (310) 264-0211 telephone | www.humanworldwide.com

Follow this link to view human’s reel online: http://www.humanworldwide.com/flash2007/?reelid=151

 _______________________________________________
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: shell script to change permissions
      • From: Christopher Nebel <email@hidden>
  • Prev by Date: Re: Rip Van Applescript
  • Next by Date: Re: Rip Van Applescript
  • Previous by thread: Zimbra
  • Next by thread: Re: shell script to change permissions
  • Index(es):
    • Date
    • Thread