There is only one basic human right, the right to do as you damn well
please. And with it comes the only basic human duty, the duty to take
the consequences. – P.J. O’Rourke
There is only one basic human right, the right to do as you damn well
please. And with it comes the only basic human duty, the duty to take
the consequences. – P.J. O’Rourke
–
General Electric - CIAT
Advanced Engineering Center
Rodrigo Bermejo
Information Technologies.
Special Applications
Dial-comm : *879-0644
Phone :(+52) 442-196-0644
in the first line of a script and it works fine. However, this doesn’t=20=
work:
#! /usr/bin/env ruby
However,
ruby hello
works fine. What am I missing?
What happens if you type “/usr/bin/env ruby --version” on the command
line? Is it possible you’ve seen it work on other computers, but env
isn’t installed on this particular one?
That’s not it. I have hello and tst1 through tst7. They are all
executable and all have the same first line. All but hello work with a
direct call. There is something about this script that is causing a
problem:
$ cat hello
#! /usr/bin/env ruby
class Hello
attr_reader :msg
def initialize @msg = “Hello, World”
end
end
h = Hello.new
puts h.msg
···
On Mar 4, 2004, at 7:56 PM, Bermejo, Rodrigo wrote:
if you are on linux/unix
works fine. What am I missing?
the ./ (dot slash) to indicate where you executable resides
$chmod +x hello
$./hello
What happens if you type “/usr/bin/env ruby --version” on the command
line? Is it possible you’ve seen it work on other computers, but env
isn’t installed on this particular one?
That was it!! Hello came from a Windows machine where lines end in
\n\r. I was trying to run it on a Unix machine where lines end in \n.
I ran ‘cat hello | tr -d ‘\r’ > tst8’, made tst8 executable and it ran.
Thanks.
Apparently, ruby itself ignores this, which is why ‘ruby hello’ worked.
I’m running BSD on a Mac PowerBook G4. However, Uwin (Unix for
Windows) has the -d and -D flags to cat that can add/remove ‘\r’.
I suppose it would be easy to write a shell script, called recode that
would do these things. I already have one called rename that allows,
for example, changing file1…file9 to file01…file09.
One of the beauties of Unix and its many variants is that it makes text
manipulation easy. Ruby seems to have similar, maybe even more
powerful, capabilities in this area, which is one of the reasons I am
trying to learn it.
···
On Mar 5, 2004, at 3:49 AM, Sascha D?rdelmann wrote: