Weird (Errno::ENOEXEC)

D

DeZo

I have a small test case that is giving weird results.

pr.rb contains:
print "Hello!"

if test.rb contains:
`pr.rb > bloop`

then running test.rb from the command line results in bloop getting created
and containing the expected test

if test.rb contains:
`pr.rb`

then running test.rb results in a runtime error:

test.rb:1:in ``': Exec format error - pr.rb

Can anyone explain what is going on? I am using the One Click installer
version 1.8.2-15.
 
K

Kero

pr.rb contains:
$ ruby test.rb
Warning: unknown mime-type for "Hello!" -- using "application/*"

$ ruby test.rb
test.rb:1: command not found: ./pr.rb

Whatever executes pr.rb (some shell, in my case "bash" in your case??) must
know that pr.rb contains *ruby* code. One way to do that, *nix style, is this:

$ cat pr.rb
#!/usr/bin/env ruby
print "Hello!"
$ cat test.rb
`./pr.rb > bloop`
$ ruby test.rb
$ cat bloop
Hello!

Another is:

$ cat pr.rb
print "Hello!"
$ cat test.rb
`ruby ./pr.rb > bloop`
$ cat bloop
Hello!

Hth,
Kero.
 
D

DeZo

Whatever executes pr.rb (some shell, in my case "bash" in your case??)
must
know that pr.rb contains *ruby* code. One way to do that, *nix style, is
this:


I'm running on Windows so I don't need to have the script identify itself.
The extension of .rb causes Windows to automatically invoke the Ruby
interpreter on it. Notice that test.rb works just fine when redirection is
included.

Are there any Windows users who can verify they have the same problem with
the code below?

#############################################################

I have a small test case that is giving weird results.

pr.rb contains:
print "Hello!"

if test.rb contains:
`pr.rb > bloop`

then running test.rb from the command line results in bloop getting created
and containing the expected test

if test.rb contains:
`pr.rb`

then running test.rb results in a runtime error:

test.rb:1:in ``': Exec format error - pr.rb

Can anyone explain what is going on? I am using the One Click installer
version 1.8.2-15.
 

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

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top