[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] (#!)^2 problem



Peter Makholm <sslug@sslug> writes:

> /tmp/plaf kaldes altså med *to* argumenter. Dels det der forekommer på
> shebang-linjen og dels navnet på det script /tmp/plaf skal 'fortolke'.
> Det mener jeg også er hvad man kunne forvente

Men det er ikke det man *bør* forvente hvis man læser SUSv3. I XCU
kapitel 2 'Shell Command Language' finder man følgende der er en del
af hvordan en shell bør forsøge at udføre et program:

    b. Otherwise, the shell executes the utility in a separate utility
       environment (see Shell Execution Environment ) with actions
       equivalent to calling the execve() function as defined in the
       System Interfaces volume of IEEE Std 1003.1-2001 with the path
       argument set to the pathname resulting from the search, arg0
       set to the command name, and the remaining arguments set to the
       operands, if any.

       If the execve() function fails due to an error equivalent to
       the [ENOEXEC] error defined in the System Interfaces volume of
       IEEE Std 1003.1-2001, the shell shall execute a command
       equivalent to having a shell invoked with the command name as
       its first operand, with any remaining arguments passed to the
       new shell. If the executable file is not a text file, the shell
       may bypass this command execution. In this case, it shall write
       an error message, and shall return an exit status of 126.

Og prøver man lige at gøre det tilsvarende:

plugh% cat > call_plaf.c 
#include <stdio.h>
#include<unistd.h>

int main() {
    int i;
    i = execve("/tmp/test.plaf",NULL,NULL);
    perror(NULL);
    return(i);
}
plugh% gcc -o call_plaf call_plaf.c
plugh% ./call_plaf               
Exec format error
plugh% 

Får man netop en ENOEXEC.


Hmmm, til sammenligning:

plugh% cat > plif
#!/usr/bin/perl -l

print for qw(foo bar baz);
plugh% chmod a+x plif 
plugh% /tmp/plif 
foo
bar
baz
plugh% cat > call_plif.c           
#include <stdio.h>
#include<unistd.h>

int main() {
    int i;
    i = execve("/tmp/plif",NULL,NULL);
    perror(NULL);
    return(i);
}
plugh% gcc -o call_plif call_plif.c
plugh% ./call_plif                 
foo
bar
baz
plugh% 

Mon pointen er at glibc/linuxkernen kun vil lave et lag af
shebang-udfoldning?

-- 
 Peter Makholm     |         Perhaps that late-night surfing is not such a
 sslug@sslug |           waste of time after all: it is just the web
 http://hacking.dk |                                              dreaming
                   |                                    -- Tim Berners-Lee


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 22:43 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *