"ruby myscript.rb" Works, "./myscript.rb" Doesn't

ruby

    Sponsored Links

    Next

  • 1. RubyCocoa and DarwinPorts Ruby?
    Can anyone point me to potential problems with setting up a RubyCocoa Framework if Ruby has been installed with DarwinPorts and thus resides in /opt/local? All comments welcome john
  • 2. Support for audio recording and analysis using Ruby?
    Hello, I was wondering if there were any modules available for Ruby to capture and analyze audio that runs on Linux. I'd like to capture short snippets of audio (0.5 to 1 second) and then do an FFT. Thanks, Wink Saville
  • 3. Q: How to initialize debugger's state when starting
    Quick question: When starting a Ruby script in debug ('-rdebug') mode, what's the simplest way to source an *rc-type file for, say, setting breakpoints? Is it possible to do such during the invocation of `ruby` at the command-line? Thanks, --J J-S
  • 4. Bug in Ripper
    Hi, Minero Aoki has confirmed that the following is a bug. I'm not (yet!) sufficinetly familiar with the Ruby internals to have a go at fixing it though :(. Any ideas? - perhaps a patch or even a hint of where to look in parse.y would help. Essentially Ripper treats the input: ='foo as an op (the =), followed by a tstring_beg (the ') and a tstring_end (foo). It should treat foo as a tstring_content. [I understand that this isn't valid ruby code, but it's not great given the expected use of Ripper to parse incomplete code (e.g. Autocompletion)]. Sample code can be found at the bottom of this post. Cheers, Jon require 'ripper/filter' class JonsFilter < Ripper::Filter def initialize(str) super str Ripper.private_instance_methods.grep(/^on_/).each { |n| m=n.to_s eval(" def " + m + "(tok, f) puts '<" + m[3..m.length-1] + ">' + escape(tok) + '</" + m[3..m.length-1] + ">' end ") } end ESC = {'&' => '&', '<' => '<', '>' => '>' } def escape(str) tbl = ESC str.gsub(/[&<>]/) {|ch| tbl[ch] } end end $input="='foo" JonsFilter.new($input).parse($stdout)

"ruby myscript.rb" Works, "./myscript.rb" Doesn't

Postby Nathan O. » Sat, 11 Mar 2006 05:35:40 GMT

I have a script. When I run it via "ruby myscript.rb", it works great. 
When I run it via "./myscript.rb", it complains:

: No such file or directory.

The top of the file starts with "#!/usr/bin/env ruby", which works for 
other scripts in the same directory. I know it's spelled right. And the 
file is set executable.

The colon (":") at the start of the error message makes me think it's 
looking for a file with no name when it should be looking for my script. 
Again, the script works great when run as a param to the "ruby..." 
command.

-- 
Posted via  http://www.**--****.com/ 



Re: "ruby myscript.rb" Works, "./myscript.rb" Doesn't

Postby Michael Gorsuch » Sat, 11 Mar 2006 05:51:31 GMT

Did you "chmod +x" the script?






Re: "ruby myscript.rb" Works, "./myscript.rb" Doesn't

Postby Michael Gorsuch » Sat, 11 Mar 2006 05:53:04 GMT

Sorry.  I just noticed that it is already executable.

What if you use the path straight to the ruby interpreter, and not /usr/bin/env?





Re: "ruby myscript.rb" Works, "./myscript.rb" Doesn't

Postby Nathan Olberding » Sat, 11 Mar 2006 06:03:47 GMT

> What if you use the path straight to the ruby interpreter, and not 

Very interesting! When I change /usr/bin/env ruby to /usr/bin/ruby 
(which is where the binary is), I get:

: bad interpreter: No such file or directory

-- 
Posted via  http://www.**--****.com/ 



Re: "ruby myscript.rb" Works, "./myscript.rb" Doesn't

Postby Michael Gorsuch » Sat, 11 Mar 2006 06:07:57 GMT

wtf?

There isn't any whitespace or blank lines before:

#!/usr/bin/ruby

is there?






Re: "ruby myscript.rb" Works, "./myscript.rb" Doesn't

Postby rmagick@gmail.com » Sat, 11 Mar 2006 06:13:27 GMT

Whenever I get weird messages like this it always turns out to be a
problem with line endings. By any chance did you last save the file on
a Windows system?


Re: "ruby myscript.rb" Works, "./myscript.rb" Doesn't

Postby Nathan Olberding » Sat, 11 Mar 2006 06:14:42 GMT



I'm glad we're on the same page. :-) Now I don't feel so alone!


nathan@vm1:~/public_html$ head -1 myscript.rb
#!/usr/bin/ruby
nathan@vm1:~/public_html$

Nada.

-- 
Posted via  http://www.**--****.com/ 



Re: "ruby myscript.rb" Works, "./myscript.rb" Doesn't

Postby Jonathan Hudson » Sat, 11 Mar 2006 06:17:20 GMT




Your script has been on a Windows box or otherwise polluted with a \r
(Carriage return) after ruby?

The kernel can't find /usr/bin/ruby\r

-jonathan

Re: "ruby myscript.rb" Works, "./myscript.rb" Doesn't

Postby Anthony DeRobertis » Sat, 11 Mar 2006 06:21:03 GMT




Windows-style line endings?






Re: "ruby myscript.rb" Works, "./myscript.rb" Doesn't

Postby Nathan Olberding » Sat, 11 Mar 2006 06:29:45 GMT

> Your script has been on a Windows box or otherwise polluted with a \r

That's it, that's the one. I had this problem with another script the 
other day. It "went away" after I did a whole bunch of stuff. This 
must've been it.

2006, and we're still dealing with line endings :-)

How do I convert it?

-- 
Posted via  http://www.**--****.com/ 



Re: "ruby myscript.rb" Works, "./myscript.rb" Doesn't

Postby Mike » Sat, 11 Mar 2006 06:33:03 GMT



Try dos2unix

-M

-- 
Posted via  http://www.**--****.com/ 



Re: "ruby myscript.rb" Works, "./myscript.rb" Doesn't

Postby Nathan Olberding » Sat, 11 Mar 2006 06:36:58 GMT

I saved it using nano and it's working now.

Thanks, all!

-- 
Posted via  http://www.**--****.com/ 



Similar Threads:

1."myscript.rb " - there's a blank in my name!

2.Piping to windows command line .rb file doesn't work

If I do this:

	home> type cat.rb

I get this output:

	print $stdin.readlines

If I do this:

	home> type cat.rb | ruby -e "print $stdin.readlines"

I get this output (NOTE, it's the same):

	print $stdin.readlines

If I type this command (.rb has been associated to ruby.exe on Win2K):

	home> type cat.rb | cat.rb

I get this output:

	cat.rb:1:in `readlines': Bad file descriptor (Errno::EBADF)
        from cat.rb:1

Any ideas why this doesn't work?

Drew

3."ruby script.rb" versus "xterm -e ruby script.rb"

4.require doesn't load non-rb files

5.smtp.rb,v 1.69 doesn't accept VERP style addressing

> Impossible.
> Please edit your protocol.rb directly.
> 
> Regards,
> Minero Aoki

Hi Minero,

I upgraded my FreeBSD machine to 1.8 and now I am getting this:

/usr/local/lib/ruby/1.8/net/smtp.rb:619:in `check_response': 501 Bad 
address syntax (Net::SMTPSyntaxError)


Locally I have: smtp.rb,v 1.64
and in production I have: smtp.rb,v 1.69

So it looks like that was a change between 1.64 and 1.69 that flags VERP 
addressing as invalid.

culley




6. protocol.rb (1.6) doesn't like VERP style addressing

7. rdoc for date.rb doesn't distinguish instance methods

8. Package, a future replacement for setup.rb and mkmf.rb



Return to ruby

 

Who is online

Users browsing this forum: No registered users and 12 guest