View previous topic :: View next topic |
Author |
Message |
skuld n00b
Joined: 13 Oct 2002 Posts: 69
|
Posted: Wed Nov 06, 2002 3:22 pm Post subject: script execution problem |
|
|
Hello,
With some bash script, I sometimes can't execute them :
Code: |
skuld@skuld# ./configure
bash: ./configure: /bin/sh: bad interpreter: Permission denied
skuld@skuld# sh ./configure
creating cache ./config.cache
checking for a BSD compatible install... /bin/install -c
checking whether build environment is sane...
...
|
but, with an other bash script, I get
Code: |
skuld@skuld# ./configure
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking whether make sets ${MAKE}... yes
...
|
the first script (the one which is not working) attributes are
Code: |
-rwxr-xr-x 1 root root 104965 Jun 5 2000 configure*
|
and code begins with
Code: |
skuld@skuld# head configure -n 1
#!/bin/sh
|
the second script attributes are
Code: |
-rwxr-xr-x 1 root root 136363 Aug 12 15:19 configure*
|
and code begins with
Code: |
skuld@skuld# head configure -n 1
#!/bin/sh
|
if someone has an idea where the problem is |
|
Back to top |
|
|
fyerk Apprentice
Joined: 17 Sep 2002 Posts: 212 Location: Atlanta, GA
|
Posted: Wed Nov 06, 2002 5:14 pm Post subject: |
|
|
It's possible that the file is in DOS format, not unix. If that's the case, the shell interprets #!/bin/sh as #!/bin/sh^M which is not a valid shell. To check if the file has DOS newlines in it, run this command:
Code: |
# perl -n -e "print if m/^M/" configure
|
If the file prints out, then it's in dos format. If not, then it's in unix format.
To replace dos newlines with unix newlines run this command:
Code: |
# perl -i.bak -p -e "s/^M$//g" configure
|
To get the ^M character, press Ctrl-V Ctrl-M _________________ -David |
|
Back to top |
|
|
skuld n00b
Joined: 13 Oct 2002 Posts: 69
|
Posted: Wed Nov 06, 2002 6:26 pm Post subject: |
|
|
It seems it's not a dos file
Code: |
bash-2.05a$ perl -n -e "print if m/^M/" configure
bash-2.05a$
|
|
|
Back to top |
|
|
fyerk Apprentice
Joined: 17 Sep 2002 Posts: 212 Location: Atlanta, GA
|
Posted: Wed Nov 06, 2002 6:53 pm Post subject: |
|
|
Try running the script using bash instead of ./
_________________ -David |
|
Back to top |
|
|
rac Bodhisattva
Joined: 30 May 2002 Posts: 6553 Location: Japanifornia
|
Posted: Wed Nov 06, 2002 6:54 pm Post subject: |
|
|
There's a huge thread about this at /bin/bash/ bad interpreter with lots of things to think about, but unfortunately it looks like it was never resolved properly. My first instinct is the same as edge's, but I worry about entering that CR directly. Does using "\r" to stand in for it have any different results? Did you transfer this file from an OS that uses DOS line endings? _________________ For every higher wall, there is a taller ladder |
|
Back to top |
|
|
skuld n00b
Joined: 13 Oct 2002 Posts: 69
|
Posted: Wed Nov 06, 2002 7:13 pm Post subject: |
|
|
edge wrote: | Try running the script using bash instead of ./
|
It works with "sh configure", so it should work with "bash configure" |
|
Back to top |
|
|
skuld n00b
Joined: 13 Oct 2002 Posts: 69
|
Posted: Wed Nov 06, 2002 7:20 pm Post subject: |
|
|
rac wrote: | Did you transfer this file from an OS that uses DOS line endings? |
It's the configure script which came with OpenUniverse tarball ( http://openuniverse.sourceforge.net )
I also had the same strange behavior with update scripts from gentoo 1.2 to gentoo 1.4 |
|
Back to top |
|
|
skuld n00b
Joined: 13 Oct 2002 Posts: 69
|
Posted: Wed Nov 06, 2002 7:33 pm Post subject: |
|
|
I found where the problem was
the scripts which weren't working where all in a partition mounted with noatime and user flags.
I umount this partition, remove the user flag in fstab, and remount it.
Now, the scripts are working very well.
Thanks for your help |
|
Back to top |
|
|
tyreth Apprentice
Joined: 27 May 2002 Posts: 238 Location: Melbourne, Australia
|
Posted: Wed Nov 13, 2002 9:03 am Post subject: |
|
|
The problem was solved for me by getting rid of noexec for /tmp! |
|
Back to top |
|
|
arkane l33t
Joined: 30 Apr 2002 Posts: 918 Location: Phoenix, AZ
|
Posted: Wed Nov 13, 2002 6:04 pm Post subject: |
|
|
tyreth wrote: | The problem was solved for me by getting rid of noexec for /tmp! |
This is a major pet peeve of mine... any script that executes code from the /tmp directory, or needs any form of execute permissions from there.
ugh...
It's a security nightmare. |
|
Back to top |
|
|
rac Bodhisattva
Joined: 30 May 2002 Posts: 6553 Location: Japanifornia
|
Posted: Wed Nov 13, 2002 9:55 pm Post subject: |
|
|
arkane wrote: | This is a major pet peeve of mine... any script that executes code from the /tmp directory, or needs any form of execute permissions from there. |
Agreed. I consider that a bug. _________________ For every higher wall, there is a taller ladder |
|
Back to top |
|
|
iwasbiggs Apprentice
Joined: 17 Jan 2003 Posts: 203
|
Posted: Fri Apr 11, 2003 6:22 pm Post subject: |
|
|
I too had similar problems. In the end, it turned out to be because I was using a custom directory for my portage compilation directory (changed to an entirely different mounted partition).
In my fstab I didn't add the exec parameter to the newly mounted drive and once I did, everything worked out. _________________ www.ruinedsoft.com
Freeware development. |
|
Back to top |
|
|
|