shebang! on Leopard

P

Paul M.

Hey everyone,

having a little trouble with shebang! on a iMac running Leopard.

been looking at the other posts and none of the solutions seem to be
working.

I'm new to Ruby, and would really like to figure this out before I move
on with my book.

So I'm trying to get this script to run:

puts "Hello, Matz!"

I ran "which ruby" from the terminal and the path says: /usr/bin/ruby

so I edited the script to:
#!/usr/bin/ruby
puts "Hello, Matz!"

and I get the following error: -bash: matz.rb: command not found

So what am I missing here?

Thanks
 
M

Matt Neuburg

Paul M. said:
Hey everyone,

having a little trouble with shebang! on a iMac running Leopard.

been looking at the other posts and none of the solutions seem to be
working.

I'm new to Ruby, and would really like to figure this out before I move
on with my book.

So I'm trying to get this script to run:

puts "Hello, Matz!"

I ran "which ruby" from the terminal and the path says: /usr/bin/ruby

so I edited the script to:
#!/usr/bin/ruby
puts "Hello, Matz!"

and I get the following error: -bash: matz.rb: command not found

So what am I missing here?

Does your script file have Unix line endings? m.
 
S

Sandor Szücs

so I edited the script to:
#!/usr/bin/ruby
puts "Hello, Matz!"

and I get the following error: -bash: matz.rb: command not found

So what am I missing here?

Your script is not in $PATH ?
try ./matz.rb

regards, Sandor Sz=FCcs
--
 
P

Paul M.

Matt said:
Does your script file have Unix line endings? m.

If you mean: pauls-imac:~ paulsimac$

Then the answer is yes.

my apologies, if I misunderstood your question.
 
H

Hassan Schroeder

it shows: -rwxr-xr-x@ 1 paulmaxfield =A0staff =A035 16 Jun 09:26 matz.rb

Wow. And in that same directory,
/matz.rb
gives you a no such file or directory message?? Strange.

Try this:
od -a matz.rb

and post the result.
 
P

Paul M.

Hassan said:
Wow. And in that same directory,
./matz.rb
gives you a no such file or directory message?? Strange.

Try this:
od -a matz.rb

and post the result.

Here you go:

0000000 # ! / u s r / b i n / r u b y nl
0000020 p u t s sp " H e l l o , sp M a t
0000040 z ! "
0000043
 
M

Matt Neuburg

Paul M. said:
If you mean: pauls-imac:~ paulsimac$

Then the answer is yes.

my apologies, if I misunderstood your question.

Could you describe *exactly* what you are doing? How are you creating
and saving the script, and then what are you doing in order to run it?

m.
 
T

Tommy Nordgren

Could you describe *exactly* what you are doing? How are you creating
and saving the script, and then what are you doing in order to run it?

m.
And have you tried each command suggested in the SAME terminal window?
Each terminal window (or rather the bash shell it invokes) have its
own current work directory.
 
P

Phil Romero

Here you go:

0000000 =C2=A0 =C2=A0# =C2=A0 ! =C2=A0 / =C2=A0 u =C2=A0 s =C2=A0 r =C2=
=A0 / =C2=A0 b =C2=A0 i =C2=A0 n =C2=A0 / =C2=A0 r =C2=A0 u =C2=A0 b =C2=A0=
y =C2=A0nl
0000020 =C2=A0 =C2=A0p =C2=A0 u =C2=A0 t =C2=A0 s =C2=A0sp =C2=A0 " =C2=
=A0 H =C2=A0 e =C2=A0 l =C2=A0 l =C2=A0 o =C2=A0 , =C2=A0sp =C2=A0 M =C2=A0=
a =C2=A0 t
0000040 =C2=A0 =C2=A0z =C2=A0 ! =C2=A0 "
0000043


You might want to make sure that /usr/bin/ruby is actually there.
It might be a broken link or gimped binary. Try this test:

/usr/bin/ruby ./matz.rb

(make sure you're rooted in the same directory as the matz.rb script
or give the full path to matz.rb). As far as I know, Leopard ships
with ruby 1.8.6 patch 87 (?), so it should be there and functioning...
This is a pretty strange problem.
 
P

Paul M.

Phil said:
You might want to make sure that /usr/bin/ruby is actually there.
It might be a broken link or gimped binary. Try this test:

/usr/bin/ruby ./matz.rb

(make sure you're rooted in the same directory as the matz.rb script
or give the full path to matz.rb). As far as I know, Leopard ships
with ruby 1.8.6 patch 87 (?), so it should be there and functioning...
This is a pretty strange problem.

Problem fixed. My mistake, when I tried the ./ I was in the wrong
directory, script is working now. Thanks everyone who took time to reply
to this post, much appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top