Monday, December 11, 2017

#1 2002-03-21 07:23:08 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Scripting Terminal

I want to copy the invisible Stickies database to an external firewire drive with the name "30 GB Firewire HD".
In the terminal, I can do this by typing the following:

Applescript:

cp ~/Library/.StickiesDatabase /Volumes/30 GB Firewire HD/.StickiesDatabase

How can I write it as an Applescript? Whenver I try I get an error.
Many thanks,
Michael


One mans trash is another mans treasure

Offline

 

#2 2002-03-21 11:07:36 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Scripting Terminal

[code:1:000]do shell script cp  ~/Library/.StickiesDatabase /Volumes/30 GB Firewire HD/.StickiesDatabase [/code:1:000]


One mans trash is another mans treasure

Offline

 

#3 2002-03-22 07:18:19 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Scripting Terminal

Applescript:

do shell script cp ~/Library/.StickiesDatabase /Volumes/30 GB Firewire HD/.StickiesDatabase

Many thanks for considering my problem, but I can't seem to make this work.

If I run as is, I get an Expected end of line error.  If I enclose it in quotes,
Applescript stops at the  GB space and says:

Expected """ but  found unknown token

What am I not understanding?


One mans trash is another mans treasure

Offline

 

#4 2002-03-23 11:19:01 am

Trash Man
Sanitation Department
Registered: 2005-10-20
Posts: 5336

Re: Scripting Terminal

: Many thanks for considering my problem, but I can't seem to make this work.
: If I run as is, I get an Expected end of line error. If I enclose it in
: quotes,
: Applescript stops at the  GB space and says: Expected """ but
: found unknown token
: What am I not understanding?


OK try something like this (obviously I've changed my user name etc):

Applescript:

tell application "Finder"
do shell script "cp /Users/andy/Library/.StickiesDatabase /Users/andy/Backups/.StickiesDatabase"
end tell

Where you put the quotes seems to make a lot of difference...


One mans trash is another mans treasure


Filed under: Finder

Offline

 

#5 2002-03-24 04:12:33 am

Krioni
Member
From:: New York, NY
Registered: 2002-11-20
Posts: 245
Website

Re: Scripting Terminal

: Many thanks for considering my problem, but I can't seem to make this work.
: If I run as is, I get an Expected end of line error. If I enclose it in
: quotes,
: Applescript stops at the  GB space and says: Expected """ but
: found unknown token
: What am I not understanding?


I've found the easiest way (and safest!) is to always put single-quotes around the path. That is, of course, unless you have single quotes in the file name. Ack!
Example:

Applescript:

do shell script cp '~/Library/.StickiesDatabase' '/Volumes/30 GB Firewire HD/.StickiesDatabase

Well, best thing is to check whatever path you put in, to make sure it is has no quotes and quote it, or escape quotes, spaces, etc if it does. I generally started leaving out spaces and quotes, slashes, etc a few years ago anyway, so that anything I did on my Mac would be cross-platform compatible. Especially important if working on websites. I use alpha-numerics, dots, dashes, and underscores. Oh well.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)