# Noob: How to make my script executable on unix?

**URL:** <https://www.ruby-forum.com/t/noob-how-to-make-my-script-executable-on-unix/80030>\
**Category:** Ruby\
**Created:** [December 20, 2006, 10:32pm UTC](https://www.ruby-forum.com/t/noob-how-to-make-my-script-executable-on-unix/80030 "2006-12-20T22:32:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 20, 2006, 10:32pm UTC](https://www.ruby-forum.com/t/noob-how-to-make-my-script-executable-on-unix/80030/1 "2006-12-20T22:32:21Z")

</div>

Hey All,

At a bash prompt, if I say ‘which ruby’, I get back  
‘/opt/csw/bin/ruby’.

So I write a 2-line test script (test.rb):  
#!/opt/csw/bin/ruby  
puts(“It works!”)

And I do a ‘chmod +x test.rb’.

But when I thereafter say ‘test.rb’, bash comes back with:  
bash: ./test.rb: bad interpreter: No such file or directory

What am I doing wrong?

Thanks!

-Roy

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 20, 2006, 11:32pm UTC](https://www.ruby-forum.com/t/noob-how-to-make-my-script-executable-on-unix/80030/2 "2006-12-20T23:32:43Z")

</div>

Hah–right you are–thanks! I’m actually on solaris, but writing my  
script on windows (ultraedit) and saving to a samba share. Ultraedit  
has a ‘DOS -\> Unix’ conversion, but it doesn’t seem to affect the  
executability of my script. ☹ But if I write the same lines to a new  
file in pico, then it works.

Thanks!

-Roy

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [December 20, 2006, 10:38pm UTC](https://www.ruby-forum.com/t/noob-how-to-make-my-script-executable-on-unix/80030/3 "2006-12-20T22:38:23Z")

</div>

removed\_email\_address@domain.invalid wrote:

> But when I thereafter say ‘test.rb’, bash comes back with:  
> bash: ./test.rb: bad interpreter: No such file or directory
> 
> What am I doing wrong?  
> Are you sure it can not be a CR/LF problem (or some other trailing  
> invisible stuff)? This is probably the most frequent cause of this  
> problem (e.g. when moving the script from win32 to linux - but since I  
> guess you are on linux only - well, I don’t know)

Otherwise, what you are doing seems fine to me…

Cheers,  
Peter

\_\_  
[http://www.rubyrailways.com](http://www.rubyrailways.com)
