Re: Error in script "invalid interpreter" (longish)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 17 Oct 2005 14:11:55 -0500
Mike McCarty <mike.mccarty@xxxxxxxxxxxxx> wrote:

> Robin Mordasiewicz wrote:
> > On Mon, 17 Oct 2005, Mike McCarty wrote:
> > 
> >> I'm trying to install lcc (compiler) from source, and encountered
> >> an error which I don't understand. During the install, a script
> >> is executed which fails. I've stripped off non-essential stuff...
> >>
> >> $ env src/run.sh
> >> env: src/run.sh: Permission denied
> >> $ pwd
> >> /mnt/cdrom/lcc/4.2
> >> $ ls -ld .
> >> dr-xr-xr-x  14 root root 4096 Oct 14 15:50 .
> >> $ ls -ld src
> >> dr-xr-xr-x  2 root root 6144 Oct 14 15:50 src
> >> $ ls -ld src/run.sh
> >> -r-xr-xr-x  1 root root 1586 Jul  2  1997 src/run.sh
> >> $ ./src/run.sh
> >> bash: ./src/run.sh: /bin/sh: bad interpreter: Permission denied
> >> $ dumphex src/run.sh
> >>
> >>
> >> 00 23 21 2F 62  69 6E 2F 73  68 0A 23 20  24 49 64 3A |#!/bin/sh.# $Id:|
> >> 10 20 72 75 6E  2E 73 68 2C  76 20 31 2E  31 31 20 31 | run.sh,v 1.11 1|
> >> 20 39 39 37 2F  30 37 2F 30  33 20 30 30  3A 31 35 3A |997/07/03 00:15:|
> >> 30 31 30 20 64  72 68 20 45  78 70 20 24  0A 23 20 72 |10 drh Exp $.# r|
> >> 40 75 6E 20 2E  2E 2E 2F 74  61 72 67 65  74 2F 6F 73 |un .../target/os|
> >> 50 2F 74 73 74  2F 66 6F 6F  2E 73 20 5B  20 72 65 6D |/tst/foo.s [ rem|
> >> 60 6F 74 65 68  6F 73 74 20  5D 0A 0A 23  20 73 65 74 |otehost ]..# set|
> >>
> >>
> >> ...
> >>
> >>
> >> $ ls -ld /bin/sh
> >> lrwxrwxrwx  1 root root 4 Oct 20  2004 /bin/sh -> bash
> >> $ ls -ld /bin/bash
> >> -rwxr-xr-x  1 root root 593304 Mar 11  2004 /bin/bash
> >> $ /bin/sh
> >> sh-2.05b$ exit
> >> exit
> >> $
> >>
> >>
> >> I thought at first that it might be the infamous MSDOS CRs at the
> >> ends of the lines, but the hex dump proves otherwise. The link
> >> /bin/sh exists, and has correct permissons, as does the file
> >> /bin/bash. It even runs.
> >>
> >> Can anyone lend me a clue? I have't got any.
> > 
> > 
> > shot in the dark. Are you running this from your home directory which is 
> > mounted via nfs and has the noexec flag set ?
> 
> I have exactly one machine. I untarred the tarball from the repo, and
> burned the files onto CDROM. The lcc website states that it is
> specifically intended to be used this way. I mounted the CDROM, and
> made it my working directory. The script is on the CDROM.
> 
> However, /bin/sh is on this machine, and it appears that /bin/sh is
> specifically what env is having troubles with. And I can run it
> directly, just not from the script.
> 
> $ pwd
> /mnt/cdrom/lcc/4.2
> 
> $ ls -ld /mnt
> drwxr-xr-x  14 root root 4096 Sep  8 17:05 /mnt
> 
> $ ls -ld /mnt/cdrom
> dr-xr-xr-x  3 root root 2048 Oct  7 10:16 /mnt/cdrom
> 
> $ ls -ld /mnt/cdrom/lcc
> dr-xr-xr-x  4 root root 2048 Oct 14 15:50 /mnt/cdrom/lcc
> 
> $ ls -ld /mnt/cdrom/lcc/4.2
> dr-xr-xr-x  14 root root 4096 Oct 14 15:50 /mnt/cdrom/lcc/4.2
> 
> $ ls -ld /mnt/cdrom/lcc/4.2/src
> dr-xr-xr-x  2 root root 6144 Oct 14 15:50 /mnt/cdrom/lcc/4.2/src
> 
> $ ls -ld /mnt/cdrom/lcc/4.2/src/run.sh
> -r-xr-xr-x  1 root root 1586 Jul  2  1997 /mnt/cdrom/lcc/4.2/src/run.sh
> 
> $ head /mnt/cdrom/lcc/4.2/src/run.sh
> #!/bin/sh
> # $Id: run.sh,v 1.11 1997/07/03 00:15:10 drh Exp $
> # run .../target/os/tst/foo.s [ remotehost ]
> 
> # set -x
> target=`echo $1 | awk -F/ '{ print $(NF-3) }'`
> os=`echo $1 | awk -F/ '{ print $(NF-2) }'`
> dir=$target/$os
> 
> case "$1" in
> 
> $ /mnt/cdrom/lcc/4.2/src/run.sh
> bash: /mnt/cdrom/lcc/4.2/src/run.sh: /bin/sh: bad interpreter: 
> Permission denied
> 
> $ /bin/sh
> sh-2.05b$ ls
> alpha  CPYRIGHT   doc  include  lib  makefile     mips    sparc  tst
> cpp    custom.mk  etc  lburg    LOG  makefile.nt  README  src    x86
> sh-2.05b$ exit
> exit
> 
> Now, the build directory is in my home tree...
> 
> $ set | grep BUILDDIR
> BUILDDIR=/home/jmccarty/build/lcc/4.2/x86-linux
> 
> $ ls -ld /home
> drwxr-xr-x  4 root root 4096 Nov  4  2004 /home
> 
> $ ls -ld /home/jmccarty
> drwxr-x---  54 jmccarty jmccarty 4096 Oct 17 12:10 /home/jmccarty
> 
> $ ls -ld /home/jmccarty/build
> drwxrwxr-x  3 jmccarty jmccarty 4096 Oct 14 15:55 /home/jmccarty/build
> 
> $ ls -ld /home/jmccarty/build/lcc
> drwxrwxr-x  3 jmccarty jmccarty 4096 Oct 14 15:55
> home/jmccarty/build/lcc
> 
> $ ls -ld /home/jmccarty/build/lcc/4.2
> drwxrwxr-x  3 jmccarty jmccarty 4096 Oct 14 16:29 
> /home/jmccarty/build/lcc/4.2
> 
> $ ls -ld /home/jmccarty/build/lcc/4.2/x86-linux
> drwxrwxr-x  5 jmccarty jmccarty 4096 Oct 17 11:50 
> /home/jmccarty/build/lcc/4.2/x86-linux
> 
> $ whoami
> jmccarty
> 
> $ finger jmccarty
> Login: jmccarty                         Name: Mike McCarty
> Directory: /home/jmccarty               Shell: /bin/bash
> On since Fri Oct 14 10:39 (CDT) on :0 (messages off)
> On since Fri Oct 14 16:17 (CDT) on pts/1 from :0.0
> On since Fri Oct 14 16:20 (CDT) on pts/3 from :0.0
>     2 days 21 hours idle
> On since Fri Oct 14 13:23 (CDT) on pts/5 from :0.0
>     3 days idle
> On since Fri Oct 14 15:28 (CDT) on pts/8 from :0.0
>     12 minutes 14 seconds idle
> No mail.
> No Plan.
> 
> 
> Mike

I believe the problem is the permissions of the files in /mnt/cdrom.
When you put in a cdrom disk the permissions of all the files on the
cdrom will be read only. Therefore you can not execute a sh script from
that area. You could copy the script to your home directory and change
it via chmod +x to allow it to run.


-- 
Richard Miles
Federal Way WA. USA
registered linux user 46097


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux