[uClinux-dev] the Kernel does not start a script

David McCullough David_Mccullough at securecomputing.com
Mon Jun 2 19:26:09 EDT 2008


Jivin Michael Schnell lays it down ...
> Hi Experts,
> 
> I'm trying to run a script on our little CPU.
> 
> By this I mean an text file that starts with
> 
> #!path_to_executable
> 
> and contains the script language text and has the executable bit set in
> the access rights.
> 
> 
> This is very useful to do simple cgi applications (here the web server -
> boa - starts the script-file it finds in "cgi-bin") or very simple
> "socket handlers" (here inetd starts the script file as denoted in
> inetd.conf).
> 
> I tested both in a PC Linux environment and it works fine (using
> bash-scripts and haserl-scrips <which in turn call bash scripts>).
> 
> Now I found that in the Kernel configuration there is a setting called
> "Kernel support for MISC binaries" (CONFIG_BINFMT_MISC). This seems to
> be necessary for executing script files. (the help on this is included
> below).


You do not need CONFIG_BINFMT_MISC IIRC, the code is in binfmt_script.c
and is always compiled in.

> Unfortunately setting this does compile, but the scripts are not
> executed anyway.
> 
> if I e.g. start msh and the  script also is supposed to use msh I get
> this (I did enable msh, ls, and cat  in busybox) :
> 
> 
> /etc/dhcpc> ls -l
> -rwxrwxrwx    1 root     root           26 Nov 29 16:47 xmsh
> /etc/dhcpc> cat xmsh
> #!/bin/msh
> /bin/ls -l /
> /etc/dhcpc> /bin/msh
> 
> 
> BusyBox v1.10.1 (2008-06-02 11:54:28 CEST) built-in shell (msh)
> Enter 'help' for a list of built-in commands.
> 
> # ./xmsh
> ./xmsh: not found
> #

Looks ok,  what happens if you run:

	/bin/msh ./xmsh

Sometimes you need to tell the shell how to load the file, for example:

	#!/usr/bin/awk -f

Cheers,
Davidm

> 
> 
> I suppose msh issues the "not found" it an error is returned be execv().
> What might prevent the Kernel from starting a script ?
> 
> 
> Looking into tzhe Kernel source I  am unable to find out what
> "CONFIG_BINFMT_MISC" really does...
> 
> 
> Any help on this ?
> 
> Thanks a lot !
> 
> -Michael
> 
> 
> 
> 
> CONFIG_BINFMT_MISC:
> 
> If you say Y here, it will be possible to plug wrapper-driven binary
> formats into the kernel. You will like this especially when you use
> programs that need an interpreter to run like Java, Python, .NET or
> Emacs-Lisp. It's also useful if you often run DOS executables under
> the Linux DOS emulator DOSEMU (read the DOSEMU-HOWTO, available from
> <http://www.tldp.org/docs.html#howto>). Once you have
> registered such a binary class with the kernel, you can start one of
> those programs simply by typing in its name at a shell prompt; Linux
> will automatically feed it to the correct interpreter.
> 
> You can do other nice things, too. Read the file
> <file:Documentation/binfmt_misc.txt> to learn how to use this
> feature, <file:Documentation/java.txt> for information about how
> to include Java support. and <file:Documentation/mono.txt> for
> information about how to include Mono-based .NET support.
> 
> To use binfmt_misc, you will need to mount it:
>      mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
> 
> You may say M here for module support and later load the module when
> you have use for it; the module is called binfmt_misc. If you
> don't know what to answer at this point, say Y.
> 
> Symbol: BINFMT_MISC [=y]
> Prompt: Kernel support for MISC binaries
>  Defined at fs/Kconfig.binfmt:115
>  Location:
>    -> Executable file formats
> 
> 
> 
> 
> _______________________________________________
> uClinux-dev mailing list
> uClinux-dev at uclinux.org
> http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
> This message was resent by uclinux-dev at uclinux.org
> To unsubscribe see:
> http://mailman.uclinux.org/mailman/options/uclinux-dev
> 

-- 
David McCullough,  david_mccullough at securecomputing.com,   Ph:+61 734352815
Secure Computing - SnapGear  http://www.uCdot.org   http://www.snapgear.com


More information about the uClinux-dev mailing list