Re: Permissions problem with script
Re: Permissions problem with script
- Subject: Re: Permissions problem with script
- From: "Mark J. Reed" <email@hidden>
- Date: Wed, 25 Jan 2006 10:45:06 -0500
On 1/25/06, Paul Thompson <email@hidden> wrote:
> -- startup disks have different names so....
> tell application "Finder" to set startupdisk to name of startup disk
You can get rid of that line; you never use the "startupdisk" variable.
>
> -- copies original printers.conf to tmp folder for modification
> do shell script ("cp /etc/cups/printers.conf /tmp/printers.conf")
> with administrator privileges
This line is your problem. You create /tmp/printers.conf with
administrator privileges, but don't use administrator privileges when
you call writeFile(). Just get rid of this line entirely - you don't
need it if you make the changes below.
-- reads original printers.conf to theText variable
> set theText to do shell script ("cat /tmp/printers.conf") with
> administrator privileges
Replace the "cat /tmp/printers.conf" here with "cat /etc/cups/printers.conf".
> -- replace text in variable theText to unsername and pass
Note that the code you have here will only work once. After that, the
"username" and "userpass" keys are gone from the file, replaced by the
actual username and password, so you won't be able to change those by
running the script again.
> -- set permissions back on the file
> do shell script ("chown root:lp /etc/cups/printers.conf") with
> administrator privileges
This step is not necessary. Copying over an existing file with "cp"
doesn't change the ownership or permissions.
> --- this handler writes the file called earlier these are an easy way
> to reuse code it can be called multiple times but only needs to be
> written once...
> on writeFile(thecontents, thefile)
> set f to (open for access (thefile) as alias with write permission)
Get rid of the "as alias" here; that way you can call writeFile()
without creating the file first; it will create it for you.
--
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:
This email sent to email@hidden