Re: terminal problems
Re: terminal problems
- Subject: Re: terminal problems
- From: "Mark J. Reed" <email@hidden>
- Date: Mon, 22 Feb 2010 12:37:27 -0500
On Sun, Feb 21, 2010 at 9:31 PM, Jarrod Coffin <email@hidden> wrote:
> Hi,
> I was recently using my terminal and was trying to run a simple program through it ( it just displayed my name and a few other things not too complicated) and as typed in ./startup.txt (name of the program) i pressed enter to execute the program but the terminal came back with the response "Permission Denied".
In order to be able to run a script as a command, you need to do two things:
1) Make the file executable
2) Tell the operating system where the interpreter for the scripting
language is.
You do #1 via the shell command "chmod +x startup.txt".
To accomplish #2, you add a special line to the very beginning of the
script file itself consisting of "#!" and the path to the interpreter.
Since "#" is sometimes called a "sharp" and "!" a "bang" when
reading code aloud, this line is called the "sharp-bang" or "shebang"
line.
If, as I might assume from the fact that you sent your query to the
Applescript list, it's written in Applescript, then you can only run
it as a command on Leopard or Snow Leopard; on Tiger and earlier the
AppleScript interpreter will choke on the shebang line and fail to run
your script. Assuming you're on * Leopard, the shebang line should
look like this:
#!/usr/bin/osascript
Note that the # and ! have to be the first and second bytes of the
file; there can be no blank lines above them and no spaces before
them.
Also, ".txt" is something of a misleading extension for something
intended to be run as a script. The suffix ".scpt" is commonly used
for Applescript code; for other languages there are language-specific
suffixes (".sh" for shell, ".pl" for Perl, etc). But the most common
choice for programs that are intended to be run as shell commands is
to have no suffix at all.
Finally, if you're just learning Applescript, I would recommend using
the Script Editor (renamed the AppleScript Editor in Snow Leopard)
instead of text files for experimentation. It's a much friendlier
environment.
_______________________________________________
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