I'm trying to write some text into an xml file situated in a subfolder of the main library/Application Support folder using a shell script do shell script "echo '" & theText & "' > " & thePath.
Without a password, I get a "sh: /Library/Application: Permission denied" which is perfectly logical. Adding user name and password, as shown in the code below, I no longer get any error, but no text is written to the file. If I put a wrong user name or password, it gives me "The user name and password were incorrect", which shows that the password is indeed being taken into account. Am I trying to do something impossible, or is my code missing something ?
set thePath to POSIX path of ("/Library/Application Support/MyApp/Stuff/test.xml" as text)
set theText to "<ProductSpecific><Visibility type=\"Number\">3</Visibility></ProductSpecific>"
set theScript to "echo '" & theText & "' > " & thePath
do shell script theScript user name "myshortusername" password "mypassword" with administrator privileges
I should get theText written to /Library/Application Support/MyApp/Stuff/test.xml but nothing is written although I don't get an error message either ! Oh, and if I move the file to the desktop and change the path, it all works fine !!