Re: error "touch: y: Permission denied"
Re: error "touch: y: Permission denied"
- Subject: Re: error "touch: y: Permission denied"
- From: Christopher Stone <email@hidden>
- Date: Wed, 22 May 2013 16:23:48 -0500
I'm unsure of what I'm bumping into here. All my attempts to create an empty text file using the touch command in a "do shell script" fail with a permission error. The command, "touch /Users/j/Desktop/bud.txt," works fine in Terminal.
Anyone know of workarounds? It has to work in AppleScript for my needs.
______________________________________________________________________
Hey J,
A new set of glasses? :) set x to path to desktop folder from user domain set y to (POSIX path of x) & "bud.txt" do shell script "touch y" -->error "touch: y: Permission denied" number 1
But seriously: a simple debugging technique that works quite often for this sort of thing:
set x to path to desktop folder from user domain set y to (POSIX path of x) & "bud.txt" set cmd to "touch " & quoted form of y --« Note the change I've made. # do shell script cmd
I always prototype do shell script commands this way and at least eyeball the output before running it.
"touch y" doesn't provide the proper path to the file. Since the sh from Applescript defaults to the root you have this permissions error. Otherwise you'd create a file and not know where it was, unless you happened to know where the working directory was.
'Quoted form of' may not be necessary if your user name is a single word, but it's good practice to use it all the time where appropriate. It saves debug time when you have spaces in a path.
-- Best Regards, Chris
|
_______________________________________________
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