Re: the difference between binary file and ASCII file

From: peter (one2001boy_at_yahoo.com)
Date: 01/14/04


Date: Wed, 14 Jan 2004 19:04:25 GMT

Carlos J. G. Duarte wrote:
> peter wrote:
>
>> hello,
>>
>> if I have a unix shell script with permission ---x--x--x,
>> how can a unix shell detect that it is not an execuable binary
>> application and gives an error message "permission denied"?
>>
>
> That is done at kernel level. The kernel first checks your permission to
> execute some file. Then get its header and if it is a binary executable,
> run the code. Otherwise, if it is some shebang (#! path stuff) it
> actually run, in user mode, the following command "path stuff
> your-file". As the program specified by "path" tries to read the file
> before interpret it, the permission denied is issued.

I think there might be a loop.
#!/bin/bash
printf("hello\n");

with permission --x--x--x.
bash kernel will send it to system() or exec() for executing if
the file is not readable (there is a chance that the file might be
binary). However, if it is some shebang #!/bin/bash, system() through sh
which calls exec() will send it to bash.

Again, bash kernal cannot read this executale code, it will send it back
to system() since bash itself cannot tell if it is binary code or not.

Not sure how shell handles this dilema.

thanks,

Peter

>
> file ~user/foo.mk with --x--x--x perms and contents:
> #! /bin/make -f
> all: ; echo all
>
> you try: exec ~user/foo.mk
> kernel checks 'x' flag, ok, then loads ~user/foo.mk, detects #! and try
> to run as :
> $ /bin/make -f ~user/foo.mk
>



Relevant Pages

  • Re: cant get each record to print separately
    ... Look at the information on fellow MVP Graham Mayor's website for which Peter gave you the link. ... your macro will save me from much physical therapy. ... bit hard to tell you exactly what commands to execute, ... written will send each of those letters to the printer as a separate print ...
    (microsoft.public.word.mailmerge.fields)
  • Re: cant get each record to print separately
    ... As Peter said, do NOT add any section breaks to the mail merge main document. ... You have not told us what version of Word you are using, which makes it a bit hard to tell you exactly what commands to execute, but you must execute the merge to a new document. ... When you execute the merge to a new document, the document that appears will contains all 155 of the five page letters with each one separated by a Section Break that is inserted automatically as part of the merge execution. ... Doug Robbins - Word MVP, ...
    (microsoft.public.word.mailmerge.fields)
  • Re: [ Attn: Randy ] Ad-hoc Parsing?
    ... One of the biggest advantages of Unix-like shells ... > flexible as the Unix scripts using the more powerful ... about bash, which being a fully-capable shell, can launch programs ... > execute the com program itself). ...
    (alt.lang.asm)
  • Re: file permissions
    ... > and stumbled across a bash script operation ... > called fileperm. ... > If I attempt to execute the file. ...
    (comp.os.linux.misc)
  • Re: Linux Command: time NO OUTPUT POSSIBLE
    ... By creating the new bash it has worked. ... But I want to execute it automaticall and therefore I have decided to ... I don't have any objection to using the GNU time program (in fact I ... The previous line says that when you execute your script (i.e., ...
    (comp.os.linux.setup)