Bad interpreter

Hi everibody,
i would start a test.rb file. I can if a type:

masarn1@gull:~$ ruby test.rb
hello, World il mio nome è Massimo

but if i type:
masarn1@gull:~$ ./test.rb
bash: ./test.rb: /usr/local/bin/ruby: bad interpreter: Permission denied

Now.
masarn1@gull:~$ which ruby
/usr/local/bin/ruby

masarn1@gull:~$ ls -l /usr/local/bin/ruby
lrwxrwxrwx 1 root root 13 dic 24 19:45
/usr/local/bin/ruby -> /usr/bin/ruby
masarn1@gull:~$ ls -l /usr/bin/ruby
-rwxr-xr-x 1 root root 3136 mar 20 2002 /usr/bin/ruby
masarn1@gull:~$

Why this not work?
Any suggestions?

Best Regards.
Massimo

···


E impari che puoi davvero sopportare,
che sei davvero forte,
e che vali davvero.


HomePage: http://spazioinwind.iol.it/arnaudo
LinuxGroup: http://www.lugge.net

Arnaudo Massimo marnaudo@inwind.it writes:

but if i type:
masarn1@gull:~$ ./test.rb
bash: ./test.rb: /usr/local/bin/ruby: bad interpreter: Permission denied

chmod +x test.rb

···


eban

[…]

but if i type:
masarn1@gull:~$ ./test.rb
bash: ./test.rb: /usr/local/bin/ruby: bad interpreter: Permission denied

Check the permissions on test.rb itself, not just the Ruby executable.
Bash erroneously reports a bad interpreter error whenever the script
itself is not executable. (There may be another reason, but this is the
most common problem.)

[…]

		Reimer Behrends
···

Arnaudo Massimo (marnaudo@inwind.it) wrote:

Hi everibody,

ciao :slight_smile:

i would start a test.rb file. I can if a type:

masarn1@gull:~$ ruby test.rb
hello, World il mio nome è Massimo

but if i type:
masarn1@gull:~$ ./test.rb
bash: ./test.rb: /usr/local/bin/ruby: bad interpreter: Permission denied

Now.
masarn1@gull:~$ which ruby
/usr/local/bin/ruby

masarn1@gull:~$ ls -l /usr/local/bin/ruby
lrwxrwxrwx 1 root root 13 dic 24 19:45
/usr/local/bin/ruby → /usr/bin/ruby
masarn1@gull:~$ ls -l /usr/bin/ruby
-rwxr-xr-x 1 root root 3136 mar 20 2002 /usr/bin/ruby
masarn1@gull:~$

Why this not work?
Any suggestions?

Maybe you imported the file from win/dos , and you’re having problems
with the termination character, this is a problem with your shell, I
supopose

···

On Mon, 6 Jan 2003 01:25:07 +0900, Arnaudo Massimo marnaudo@inwind.it wrote:

masarn1@gull:~$ ls -l /usr/bin/ruby
-rwxr-xr-x 1 root root 3136 mar 20 2002 /usr/bin/ruby

                                         ^^^^

masarn1@gull:~$

This is a shell script or what ?

Guy Decoux

In article 20030105144216.GA2879@gull.zena.it,
Arnaudo Massimo marnaudo@inwind.it writes:

Hi everibody,
i would start a test.rb file. I can if a type:

masarn1@gull:~$ ruby test.rb
hello, World il mio nome è Massimo

but if i type:
masarn1@gull:~$ ./test.rb
bash: ./test.rb: /usr/local/bin/ruby: bad interpreter: Permission denied

I always found the solution of these kind of problems by
‘strace ./test.rb 2> output’
and looking at output.

Hope that helps,
Martin.

Arnaudo Massimo marnaudo@inwind.it writes:

but if i type:
masarn1@gull:~$ ./test.rb
bash: ./test.rb: /usr/local/bin/ruby: bad interpreter: Permission denied

chmod +x test.rb

masarn1@gull:~$ chmod +x test.rb
masarn1@gull:~$ ./test.rb
bash: ./test.rb: /usr/local/bin/ruby: bad interpreter: Permission denied
masarn1@gull:~$
…do not work yet

Massimo

···


E impari che puoi davvero sopportare,
che sei davvero forte,
e che vali davvero.


HomePage: http://spazioinwind.iol.it/arnaudo
LinuxGroup: http://www.lugge.net

Hi everibody,

ciao :slight_smile:

Riciao :>

Maybe you imported the file from win/dos , and you’re having problems
with the termination character, this is a problem with your shell, I
supopose

No, i have created and edit where it is: home directory in linux

The strange thing is that when i exec it from root user, it do not
works:

masarn1@gull:~$ su
Password:
gull:/home/masarn1# ./test.rb
bash: ./test.rb: /usr/local/bin/ruby: bad interpreter: Permission denied
gull:/home/masarn1

Massimo

···

On Mon, 6 Jan 2003 01:25:07 +0900, Arnaudo Massimo > marnaudo@inwind.it wrote:

E impari che puoi davvero sopportare,
che sei davvero forte,
e che vali davvero.


HomePage: http://spazioinwind.iol.it/arnaudo
LinuxGroup: http://www.lugge.net

  • Martin Kahlert mkcon@gmx.de [giovedì 09 gennaio 2003, alle 16:36]:

I always found the solution of these kind of problems by
‘strace ./test.rb 2> output’
and looking at output.

Hope that helps,
Martin.

masarn1@gull:~/Ruby$ ./test.rb 2> error.log
masarn1@gull:~/Ruby$ cat error.log
bash: ./test.rb: /usr/local/bin/ruby: bad interpreter: Permission denied
masarn1@gull:~/Ruby$

Hhmm, this is not chage the answer!

Ciao
Massimo

···


E impari che puoi davvero sopportare,
che sei davvero forte,
e che vali davvero.


HomePage: http://spazioinwind.iol.it/arnaudo
LinuxGroup: http://www.lugge.net

masarn1@gull:~$ ls -l /usr/bin/ruby
-rwxr-xr-x 1 root root 3136 mar 20 2002 /usr/bin/ruby
^^^^
masarn1@gull:~$

This is a shell script or what ?

Guy Decoux

This is not a shell script:

ELF

chmod 755 test.rb

···

On Mon, Jan 06, 2003 at 09:55:29PM +0900, Arnaudo Massimo wrote:

Arnaudo Massimo marnaudo@inwind.it writes:

but if i type:
masarn1@gull:~$ ./test.rb
bash: ./test.rb: /usr/local/bin/ruby: bad interpreter: Permission denied

chmod +x test.rb

masarn1@gull:~$ chmod +x test.rb
masarn1@gull:~$ ./test.rb
bash: ./test.rb: /usr/local/bin/ruby: bad interpreter: Permission denied
masarn1@gull:~$
…do not work yet


_ _

__ __ | | ___ _ __ ___ __ _ _ __
'_ \ / | __/ __| '_ _ \ / ` | ’ \
) | (| | |
__ \ | | | | | (| | | | |
.__/ _,
|_|/| || ||_,|| |_|
Running Debian GNU/Linux Sid (unstable)
batsman dot geo at yahoo dot com

You will not censor me through bug terrorism.
– James Troup

No, i have created and edit where it is: home directory in linux

The strange thing is that when i exec it from root user, it do not
works:

masarn1@gull:~$ su
Password:
gull:/home/masarn1# ./test.rb
bash: ./test.rb: /usr/local/bin/ruby: bad interpreter: Permission denied
gull:/home/masarn1

Massimo

1)Check where is your ruby interpreter
(from the shell : “which ruby”).

Maybe you have another one in your path , and no perm over it.

maybe try

#!/path/to/env ruby

instead of

#!/path/to/ruby

as

the first line of the script.

O il contrario :slight_smile:

(last :

[loser@irc ted]$ ./tst.rb
bash: ./tst.rb: bad interpreter: No such file or directory
[loser@irc ted]$ cat tst.rb
#!ur/local/bin/ruby
puts "hello world
[loser@irc ted]$

Now, the path to ruby is wrong , I don’t get your same error, but
trying costs nothing :slight_smile:

Hi –

···

On Fri, 10 Jan 2003, Arnaudo Massimo wrote:

  • Martin Kahlert mkcon@gmx.de [giovedì 09 gennaio 2003, alle 16:36]:

I always found the solution of these kind of problems by
‘strace ./test.rb 2> output’
and looking at output.

Hope that helps,
Martin.

masarn1@gull:~/Ruby$ ./test.rb 2> error.log
masarn1@gull:~/Ruby$ cat error.log
bash: ./test.rb: /usr/local/bin/ruby: bad interpreter: Permission denied
masarn1@gull:~/Ruby$

Hhmm, this is not chage the answer!

You forgot the ‘strace’ :slight_smile:

David


David Alan Black
home: dblack@candle.superlink.net
work: blackdav@shu.edu
Web: http://pirate.shu.edu/~blackdav

masarn1@gull:~/Ruby$ ./test.rb 2> error.log
masarn1@gull:~/Ruby$ cat error.log
bash: ./test.rb: /usr/local/bin/ruby: bad interpreter: Permission denied
masarn1@gull:~/Ruby$

Hhmm, this is not chage the answer!

you missed “strace”.

strace ./test.rb 2>err.log

···

Ciao
Massimo

masarn1@gull:~$ chmod +x test.rb
masarn1@gull:~$ ./test.rb
bash: ./test.rb: /usr/local/bin/ruby: bad interpreter: Permission denied
masarn1@gull:~$
…do not work yet

chmod 755 test.rb

masarn1@gull:~$ chmod 755 test.rb
masarn1@gull:~$ ./test.rb
bash: ./test.rb: /usr/local/bin/ruby: bad interpreter: Permission denied
masarn1@gull:~

Nothing!

···


E impari che puoi davvero sopportare,
che sei davvero forte,
e che vali davvero.


HomePage: http://spazioinwind.iol.it/arnaudo
LinuxGroup: http://www.lugge.net

masarn1@gull:~/Ruby$ ./test.rb 2> error.log
masarn1@gull:~/Ruby$ cat error.log
bash: ./test.rb: /usr/local/bin/ruby: bad interpreter: Permission denied
masarn1@gull:~/Ruby$

Maybe ruby is not in /usr/local/bin. Or it is not in your
PATH environment var, so #!/usr/bin/env ruby failed

Thinks to check:
$ whereis ruby - will give you full path to ruby
$ ruby ./test.rb - is ruby in your PATH environment var

Maybe correction of first line in the script will be needed:

— test.rb —
#!/put/here/the/right/path/ruby

···


________ Stoyan Zhekov <sto [AT] zhware [DOT] net> ________
OpenPGP: gpg --keyserver pgp.mit.edu --recv-keys 3CA641A8
fpr: 2A61 58D0 A69C FF68 4785 A0A3 89DE AEC0 3CA6 41A8
____________ Is there life after /sbin/halt -p? _____________

you missed “strace”.

Ops!

masarn1@gull:~/Ruby$ strace ./test3.rb 2> err3.log
masarn1@gull:~/Ruby$ cat err3.log
execve(“./test3.rb”, [“./test3.rb”], [/* 15 vars */]) = 0
strace: exec: Permission denied
masarn1@gull:~/Ruby$

Ciao
Massimo

···


E impari che puoi davvero sopportare,
che sei davvero forte,
e che vali davvero.


HomePage: http://spazioinwind.iol.it/arnaudo
LinuxGroup: http://www.lugge.net

Silly question: is /usr/local/bin/ruby executable?

···

On Thu, 9 Jan 2003, Arnaudo Massimo wrote:

masarn1@gull:~$ chmod +x test.rb
masarn1@gull:~$ ./test.rb
bash: ./test.rb: /usr/local/bin/ruby: bad interpreter: Permission denied
masarn1@gull:~$
…do not work yet

chmod 755 test.rb

masarn1@gull:~$ chmod 755 test.rb
masarn1@gull:~$ ./test.rb
bash: ./test.rb: /usr/local/bin/ruby: bad interpreter: Permission denied
masarn1@gull:~

Nothing!

E impari che puoi davvero sopportare,
che sei davvero forte,
e che vali davvero.


HomePage: http://spazioinwind.iol.it/arnaudo
LinuxGroup: http://www.lugge.net

masarn1@gull:~/Ruby$ ./test.rb 2> error.log
masarn1@gull:~/Ruby$ cat error.log
bash: ./test.rb: /usr/local/bin/ruby: bad interpreter: Permission denied
masarn1@gull:~/Ruby$

Maybe ruby is not in /usr/local/bin. Or it is not in your
PATH environment var, so #!/usr/bin/env ruby failed

Thinks to check:
$ whereis ruby - will give you full path to ruby

masarn1@gull:~/Ruby$ which ruby
/usr/local/bin/ruby
masarn1@gull:~/Ruby$ ls -l /usr/local/bin/ruby
masarn1@gull:~/Ruby$ ls -l /usr/local/bin/ruby
lrwxrwxrwx 1 root root 13 dic 24 19:45 /usr/local/bin/ruby → /usr/bin/ruby
masarn1@gull:~/Ruby$ ls -l /usr/bin/ruby
-rwxr-xr-x 1 root root 3136 mar 20 2002 /usr/bin/ruby
masarn1@gull:~/Ruby$

$ ruby ./test.rb - is ruby in your PATH environment var

masarn1@gull:~/Ruby$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games:/home/masarn1/Ruby
masarn1@gull:~/Ruby$ ./test3.rb
bash: ./test3.rb: /usr/local/bin/ruby: bad interpreter: Permission denied
masarn1@gull:~/Ruby$

Maybe correction of first line in the script will be needed:

— test.rb —
#!/put/here/the/right/path/ruby

masarn1@gull:~/Ruby$ cat test3.rb
#!/usr/local/bin/ruby

puts “Hello, World”

masarn1@gull:~/Ruby$

I think it is all right. I can not understand why i have this problem …

Ciao
Massimo

···


E impari che puoi davvero sopportare,
che sei davvero forte,
e che vali davvero.


HomePage: http://spazioinwind.iol.it/arnaudo
LinuxGroup: http://www.lugge.net

#!/usr/local/bin/ruby

puts “Hello, World”

masarn1@gull:~/Ruby$

I think it is all right. I can not understand why i have this problem

What happens when you call /usr/local/bin/ruby straight from the command
line?

···

On Sun, 12 Jan 2003 02:41:49 +0900 Arnaudo Massimo marnaudo@inwind.it wrote:

Ciao
Massimo

E impari che puoi davvero sopportare,
che sei davvero forte,
e che vali davvero.


HomePage: http://spazioinwind.iol.it/arnaudo
LinuxGroup: http://www.lugge.net


“Daniel P. Zepeda” <daniel@z,e,p,e,d,a,-,z,o,n,e.net>
(Remove commas for address)