I have two commands that I need to run through the Terminal. They are
cd /Users/[my name]/Desktop and curl 'www.google.com'>google.txt. When running these directly in Terminal they work just fine. However, when running this in AppleScript:

do shell script "cd /Users/Peter1/Desktop"
do shell script "curl 'www.google.com'>google.txt"

It produced the error:

sh: google.txt: Permission denied

Why is this happening? What can I do to fix it?


1 Answer 1


Your script above is running two different scripts. One is changing the working directory to your user desktop folder (~/Desktop). The other script is downloading www.google.com and putting it in a document in your root directory (/), which doesn't have permissions to do so.

You can fix this by reduce it to one statement of do shell script like such:

do shell script "curl www.google.com > ~/Desktop/google.txt"

In short, the script first downloads the contents of the website www.google.com and then creates a new file at the specified directory. You may also notice the ~ character, which is equivalent to /Users/username/.

  • Ah, OK, thanks. I was thinking that the first command turns the working directory to the desktop, and the second saves a file there (on the desktop)
    – APCoding
    Jul 25, 2015 at 2:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .