Re: Copy folder shell scripting
Re: Copy folder shell scripting
- Subject: Re: Copy folder shell scripting
- From: "Mark J. Reed" <email@hidden>
- Date: Thu, 24 Apr 2008 10:35:52 -0400
On Thu, Apr 24, 2008 at 10:24 AM, ba95 <email@hidden> wrote:
> 1- What do I put at the beginning/end of the shell script ?
> 2- What extension do I put to the shell script fille, so that it will be
> recognized ?
The answers to both of those questions depend on how you are going to
be running the script.
If you just want to be able to type the name of the script at the
command line (e.g. in Terminal), then you don't have to put anything
in front of the command or give it any special extension. You just
need to give it execute permission (don't type the $, that represents
the prompt):
$ chmod +x myscript
and put it somewhere your shell will find it..
$ mkdir ~/bin
$ mv myscript ~/bin
Then you can just type
$ myscript
and it will run.
A shell script is just a series of commands, one per line, entered
exactly as you would type them in a Terminal. One of the reasons
command-line interfaces are as powerful as they are is that there's no
difference between the user interface and the automation interface; if
you know how to do something manually, you automatically know how to
script it. No dictionary required.
The #!/bin/sh at the top of the file allows the system to treat it as
an executable program. It's not necessary when you run it from the
shell, but good practice to put it there anyway. You can put any kind
of interpreter name after the #! and it will work,. for instance
#!/usr/bin/osascript
path to me
works (at least on Leopard; a niggling memory is telling me that you
might have to add an option after the /osascript to get it to work on
earlier versions of OS X).
However, the #! line is itself included in the input fed to the
interpreter, so this trick won't work if the interpreter is confused.
# is normally a comment to the shell, so that's not a problem, but
programs like osascript have to have the ability to handle that line
built in.
--
Mark J. Reed <email@hidden>
_______________________________________________
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