Streaming Audio: revisited (again)
Geert Janssens
geert.janssens3 at pandora.be
Thu May 26 09:19:46 MDT 2005
On Thursday 26 May 2005 16:27, Eric Dunbar wrote:
> What does that first line in a script do?
>
> In bash scripts there's a #bash... line at the start. What does that
> tell bash to do?
>
It's not #bash
but #! /bin/bash
You could call this line the "file type" of the script.
Here is some more explanation:
Suppose you have written a script in some scripting language. There is two
ways to invoke this script from the command line (or more precisely: from the
bash interactive shell):
1. invoke the script interpreter directly with your script as a parameter.
Some examples:
ydl$ /bin/bash /home/myhome/my-bash-shell-script
ydl$ /usr/bin/perl some-perl-script
2. make the script executable, and invoke it directly
Some examples:
ydl$ chmod +x my-bash-shell-script
ydl$ /home/myhome/my-bash-shel-script
ydl$ chmod +x some-perl-script
ydl$ ./some-perl-script
In this case, bash tries to figure out which script interpreter should be
invoked, and then executes it with the script as a parameter. So in this case
bash calls the script as in option 1. for you.
The big question is, how does bash know which interpreter is needed ?
The answer: it's encoded in the first line of the script:
If it says #! /bin/bash
bash will simply execute /bin/bash with your script as a parameter.
If it says #! /usr/bin/perl
well, I suppose you get it by now.
Note that you can add command line parameters to the interpreter.
For example, to debug a bash shell script, you could alter the first line to
#! /bin/bash -x
to get a printout of execution information while the script is running, or
#! /bin/bash -v
to get each statement printed to standard out before it gets executed (useful
to figure out which portions of the script are being executed and which not).
In the same way
#! /usr/bin/perl -w
will cause the script to generate stricter warnings (if my limited perl
knowledge is correct).
Hth
Geer Jan
> Eric.
>
> On 5/26/05, Chris Kastorff <jckastorff at ix.netcom.com> wrote:
> > I have found a better way (better than curl, kill) during my work
> > with Perl. No killing, one cron job. The script linked to must be set
> > +x (chmod +x file), and the first line should be set to #!/path/to/
> > perl (which may be /usr/local/bin/perl or /usr/bin/perl or some other
>
> _______________________________________________
> yellowdog-general mailing list
> yellowdog-general at lists.terrasoftsolutions.com
> http://lists.terrasoftsolutions.com/mailman/listinfo/yellowdog-general
> HINT: to Google archives, try '<keywords> site:terrasoftsolutions.com'
More information about the yellowdog-general
mailing list