Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
script execution problem
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
skuld
n00b
n00b


Joined: 13 Oct 2002
Posts: 69

PostPosted: Wed Nov 06, 2002 3:22 pm    Post subject: script execution problem Reply with quote

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
View user's profile Send private message
fyerk
Apprentice
Apprentice


Joined: 17 Sep 2002
Posts: 212
Location: Atlanta, GA

PostPosted: Wed Nov 06, 2002 5:14 pm    Post subject: Reply with quote

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
View user's profile Send private message
skuld
n00b
n00b


Joined: 13 Oct 2002
Posts: 69

PostPosted: Wed Nov 06, 2002 6:26 pm    Post subject: Reply with quote

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
View user's profile Send private message
fyerk
Apprentice
Apprentice


Joined: 17 Sep 2002
Posts: 212
Location: Atlanta, GA

PostPosted: Wed Nov 06, 2002 6:53 pm    Post subject: Reply with quote

Try running the script using bash instead of ./

Code:

# bash configure

_________________
-David
Back to top
View user's profile Send private message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Wed Nov 06, 2002 6:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
skuld
n00b
n00b


Joined: 13 Oct 2002
Posts: 69

PostPosted: Wed Nov 06, 2002 7:13 pm    Post subject: Reply with quote

edge wrote:
Try running the script using bash instead of ./

Code:

# bash configure


It works with "sh configure", so it should work with "bash configure"
Back to top
View user's profile Send private message
skuld
n00b
n00b


Joined: 13 Oct 2002
Posts: 69

PostPosted: Wed Nov 06, 2002 7:20 pm    Post subject: Reply with quote

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
View user's profile Send private message
skuld
n00b
n00b


Joined: 13 Oct 2002
Posts: 69

PostPosted: Wed Nov 06, 2002 7:33 pm    Post subject: Reply with quote

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
View user's profile Send private message
tyreth
Apprentice
Apprentice


Joined: 27 May 2002
Posts: 238
Location: Melbourne, Australia

PostPosted: Wed Nov 13, 2002 9:03 am    Post subject: Reply with quote

The problem was solved for me by getting rid of noexec for /tmp!
Back to top
View user's profile Send private message
arkane
l33t
l33t


Joined: 30 Apr 2002
Posts: 918
Location: Phoenix, AZ

PostPosted: Wed Nov 13, 2002 6:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Wed Nov 13, 2002 9:55 pm    Post subject: Reply with quote

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
View user's profile Send private message
iwasbiggs
Apprentice
Apprentice


Joined: 17 Jan 2003
Posts: 203

PostPosted: Fri Apr 11, 2003 6:22 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum