Hi,
I tried to to add an extra PATH to the /etc/paths file with the script :
set writePath to open for access file ("etc:paths") with write permission
try
write "/usr/bin/engines" to writePath starting at eof
close access writePath
on error
try
close access writePath
end try
end try
the result is “error “Network file permission error.” number -5000 from file “Macbook:private:etc:paths” to «class fsrf»”
maybe it’s a bit long-winded, but it works.
The script reads /private/etc/paths,
adds the line, writes the data into a (user owned) temp file,
overwrites /private/etc/paths with the temp file and restores the proper privileges
property paths : "/private/etc/paths"
property pw : "¢¢¢¢¢¢" -- admin password
set pathsTemp to ((path to temporary items as text) & "paths")
set theData to read POSIX file paths
try
set ff to open for access file pathsTemp with write permission
write (theData & "/usr/bin/engines" & linefeed) to ff
close access ff
do shell script "mv " & quoted form of POSIX path of pathsTemp & space & paths password pw with administrator privileges
do shell script "chown root:wheel " & paths password pw with administrator privileges
do shell script "chmod 644 " & paths password pw with administrator privileges
on error
try
close access file pathsTemp
end try
end tr