Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a ruby file saved on my desktop as test.rb. How can I open it with terminal? I have already tried to use /home/desktop/test.rb and what I get in response is bash: /home/desktop/test.rb: No such file or directory.

share|improve this question
add comment

3 Answers

You can use the ruby command, which calls the Ruby interpreter on your file:

ruby ~/Desktop/test.rb

This way you don't need to make your file executable.

(The tilde symbol ~ is a shorthand for the path to your home folder which is /home/<your-username>.)

If you still need to make your script executable I hope you remembered to type the shebang line on the first line of your script:

#!/usr/bin/ruby

then run chmod +x ~/Desktop/test.rb on the terminal to make test.rb executable.

share|improve this answer
    
Thank you very much. –  user164814 Jun 6 '13 at 14:25
    
If this post answered your question, please mark it as the answer. –  Tass Mar 10 at 18:48
add comment

/home/<username>/ is the path of your home-directory. If you start your Terminal, your Shell starts in your home-directory, you can print that path with the command

$ pwd

The you need the path of the Desktop-Folder, try it with

$ ls

Your final command than will probably look like that:

~$ ./Desktop/test.rb

But you should try a tutorial for the Linux shell, like this one: LinuxCommand.org

share|improve this answer
    
Thank you, but it says access denied, what can I do? –  user164814 Jun 6 '13 at 1:45
    
The file isn't executable. Try chmod +x ./Desktop/test.rb and after that try to execute the file again. If you want to know more try man chmod (can be closed by tipping 'q') –  tvn Jun 6 '13 at 1:51
    
Worked like a charm, thank you! –  user164814 Jun 6 '13 at 14:14
add comment

Your home directory is /home/<your username>/. Your Desktop is /home/<your username>/Desktop.

You forgot the <your username> part of it.

share|improve this answer
    
That didn't quite work. –  user164814 Jun 6 '13 at 14:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.