From: Mark Rosenstand <mark@borkware.net>
To: Arjan van de Ven <arjan@infradead.org>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Executable shell scripts
Date: Sat, 13 May 2006 13:17:13 +0200 (CEST) [thread overview]
Message-ID: <20060513111713.8031C146CA@hunin.borkware.net> (raw)
In-Reply-To: <1147518432.3217.2.camel@laptopd505.fenrus.org>
Arjan van de Ven <arjan@infradead.org> wrote:
> On Sat, 2006-05-13 at 13:03 +0200, Mark Rosenstand wrote:
> > Arjan van de Ven <arjan@infradead.org> wrote:
> > > On Sat, 2006-05-13 at 12:38 +0200, Mark Rosenstand wrote:
> > > > Hi,
> > > >
> > > > Is it in any (reasonable) way possible to make Linux support executable
> > > > shell scripts? Perhaps through binfmt_misc?
> > >
> > > ehhhhhh this is already supposed to work.
> >
> > It doesn't:
> >
> > bash-3.00$ cat << EOF > test
> > > #!/bin/sh
> > > echo "yay, I'm executing!"
> > > EOF
> > bash-3.00$ chmod 111 test
> > bash-3.00$ ./test
> > /bin/sh: ./test: Permission denied
>
> is your script readable as well? 111 is just weird/odd.
No, it's executable. This is what makes executable shell scripts
distinct from feeding the file to an interpreter.
>From http://www.faqs.org/faqs/unix-faq/faq/part4/section-7.html:
The script is called `executable' because just like a real
(binary) executable it starts with a so-called `magic number'
indicating the type of the executable. In our case this number is
`#!' and the OS takes the rest of the first line as the
interpreter for the script, possibly followed by 1 initial option
like:
#!/bin/sed -f
Suppose this script is called `foo' and is found in /bin,
then if you type:
foo arg1 arg2 arg3
the OS will rearrange things as though you had typed:
/bin/sed -f /bin/foo arg1 arg2 arg3
There is one difference though: if the setuid permission bit for
`foo' is set, it will be honored in the first form of the
command; if you really type the second form, the OS will honor
the permission bits of /bin/sed, which is not setuid, of course.
next prev parent reply other threads:[~2006-05-13 11:17 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-13 10:38 Mark Rosenstand
2006-05-13 10:56 ` Arjan van de Ven
2006-05-13 11:03 ` Mark Rosenstand
2006-05-13 11:07 ` Arjan van de Ven
2006-05-13 11:17 ` Mark Rosenstand [this message]
2006-05-13 11:18 ` Willy Tarreau
2006-05-13 11:19 ` Douglas McNaught
2006-05-13 11:27 ` Mark Rosenstand
2006-05-13 11:37 ` Joel Jaeggli
2006-05-13 12:59 ` Theodore Tso
2006-05-13 13:18 ` Mark Rosenstand
2006-05-13 22:42 ` Neil Brown
2006-05-13 11:28 ` Stefan Smietanowski
2006-05-13 11:37 ` Neil Brown
2006-05-13 12:45 ` Willy Tarreau
2006-05-13 14:00 ` Arjan van de Ven
2006-05-13 20:52 ` Douglas McNaught
2006-05-13 11:16 ` J.A. Magallón
2006-05-13 11:22 ` Bernd Petrovitsch
2006-05-13 11:45 ` Mark Rosenstand
2006-05-13 11:56 ` Bernd Petrovitsch
2006-05-13 12:23 ` Mark Rosenstand
2006-05-13 12:58 ` Willy Tarreau
2006-05-13 18:55 ` Bernd Petrovitsch
2006-05-13 11:23 ` CaT
2006-05-13 11:00 ` Willy Tarreau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060513111713.8031C146CA@hunin.borkware.net \
--to=mark@borkware.net \
--cc=arjan@infradead.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®