Re: the difference between binary file and ASCII file
From: peter (one2001boy_at_yahoo.com)
Date: 01/14/04
- Next message: Daz: "Bourne Shell Script Newbie Help"
- Previous message: Stephane CHAZELAS: "Re: Testing time in a korn shell script"
- In reply to: Carlos J. G. Duarte: "Re: the difference between binary file and ASCII file"
- Next in thread: Carlos J. G. Duarte: "Re: the difference between binary file and ASCII file"
- Reply: Carlos J. G. Duarte: "Re: the difference between binary file and ASCII file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
>
- Next message: Daz: "Bourne Shell Script Newbie Help"
- Previous message: Stephane CHAZELAS: "Re: Testing time in a korn shell script"
- In reply to: Carlos J. G. Duarte: "Re: the difference between binary file and ASCII file"
- Next in thread: Carlos J. G. Duarte: "Re: the difference between binary file and ASCII file"
- Reply: Carlos J. G. Duarte: "Re: the difference between binary file and ASCII file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|