Re: Need Root Access to etc/rc
Re: Need Root Access to etc/rc
- Subject: Re: Need Root Access to etc/rc
- From: John Stewart <email@hidden>
- Date: Sat, 18 Jan 2003 06:04:46 -0500
On Friday, January 17, 2003, at 06:52 PM, Johnny AppleScript wrote:
Hello,
I need a sample script that will give me root access to use write
permissions on etc/rc.
The following works perfectly while logged in as root; I need an
addition
that will allow an admin user to gain access:
tell application "Finder"
try
set pathstring to "etc:rc"
if exists pathstring then
set theFile to open for access file pathstring with write
permission
set theContents to read theFile
close access theFile
return pathstring
end if
on error errMsg number errNum
try
close access file pathstring
end try
error errMsg number errNum
end try
end tell
Anybody?
I'm not quite sure what you are trying to accomplish but this script
reads /etc/rc just fine OMM with no need for additional authentication.
(* start script *)
try
set pathstring to (path to startup disk as string) & "private:etc:rc"
tell application "Finder" to set theContents to read alias pathstring
(* the line above will generate an error if the file doesn't exist *)
return theContents
on error errMsg number errNum
display dialog (errNum as string) & ": " & errMsg
end try
(* end script *)
If you are only checking the existence of the file there is no need to
read it and still no need for authentication.
(* start script *)
try
set pathstring to (path to startup disk as string) & "private:etc:rc"
tell application "Finder" to alias pathstring
on error errMsg number errNum
display dialog (errNum as string) & ": " & errMsg
end try
(* end script *)
If you are just checking it's contents there is no need for write
access and if you just "read" (i.e. no "open for access") there's no
need to close it.
If you are attempting to modify it that's an altogether different
proposition and feel free contact me off list if that's the case.
John
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.