Find the answer to your Linux question:
Results 1 to 9 of 9
I have installed ruby-1.8.2-11.8.i586.rpm into my Suse 10.2 Machine. How do i run my scripts? Please Help. The-Wise-Man...
  1. #1
    Just Joined! The-Wise-Man's Avatar
    Join Date
    May 2007
    Location
    Out in the woods with the only computer for 169 miles.
    Posts
    62

    Post Ruby

    I have installed ruby-1.8.2-11.8.i586.rpm into my Suse 10.2 Machine. How do i run my scripts? Please Help.



    The-Wise-Man

  2. #2
    Linux Guru bryansmith's Avatar
    Join Date
    Nov 2004
    Location
    /Ontario/Canada
    Posts
    2,621
    Type:
    Code:
    ruby <name of script>
    So, if your script was in your ~/scripts folder, you could do one of two things:
    Code:
    ruby ~/scripts/<script name>
    or
    Code:
    cd ~/scripts
    ruby <name of script>
    Hope that helps.
    Looking for a distro? Look here.
    "There can be no doubt that all our knowledge begins with experience." - Immanuel Kant (Critique of Pure Reason)
    Queen's University - Arts and Science 2008 (Sociology)
    Registered Linux User #386147.

  3. #3
    Just Joined! The-Wise-Man's Avatar
    Join Date
    May 2007
    Location
    Out in the woods with the only computer for 169 miles.
    Posts
    62
    Casey@linux:~> ruby '/home/Casey/Desktop/testing.rb'
    /home/Casey/Desktop/testing.rb:1: syntax error, unexpected tIDENTIFIER, expecting $end
    puts 'Casey it's Working great'
    ^
    Casey@linux:~> su
    Password:
    linux:/home/Casey # ruby '/home/Casey/Desktop/testing.rb'
    /home/Casey/Desktop/testing.rb:1: syntax error, unexpected tIDENTIFIER, expecting $end
    puts 'Casey it's Working great'
    ^
    linux:/home/Casey #


    Error

  4. #4
    Linux Guru bryansmith's Avatar
    Join Date
    Nov 2004
    Location
    /Ontario/Canada
    Posts
    2,621
    There is no need to make the text large to make the point.

    Could you please post your code here as there appears to be a syntax error with your code.
    Looking for a distro? Look here.
    "There can be no doubt that all our knowledge begins with experience." - Immanuel Kant (Critique of Pure Reason)
    Queen's University - Arts and Science 2008 (Sociology)
    Registered Linux User #386147.

  5. #5
    Just Joined! The-Wise-Man's Avatar
    Join Date
    May 2007
    Location
    Out in the woods with the only computer for 169 miles.
    Posts
    62

    Post

    The Ruby program? i just made a testing 1 it looks like this

    puts 'Testing'
    gets





    When i try to type ruby name of script nothing happens cant even type in Konsole



    The-Wise-Man

  6. #6
    Linux Guru gogalthorp's Avatar
    Join Date
    Oct 2006
    Location
    West (by God) Virginia
    Posts
    3,105
    You must invoke ruby to run a ruby script. In the first case above The error looks like a shell script error. So you simply typed "test.rb" you must type

    ruby test.rb

    Linux knows nothing about extensions. So it sees the text only as text. If you flag the text as executable and it is not a binary then the shell program will attempt to execute the text as a shell script. Note some extension recognition is normally in the GUI's ie you can associate extensions with certain programs. You could associate .rb with ruby then when a .rb file is clicked it is opened with the ruby program. But this is a property of the GUI not of the console or Linux kernel. There is no difference with this then with windows and DOS shells in the MS world.

  7. #7
    Just Joined! The-Wise-Man's Avatar
    Join Date
    May 2007
    Location
    Out in the woods with the only computer for 169 miles.
    Posts
    62
    Thats what im doing but then i get this error



    Casey@linux:~> ruby '/home/Casey/Desktop/testing.rb'
    /home/Casey/Desktop/testing.rb:1: syntax error, unexpected tIDENTIFIER, expecting $end
    puts 'Casey it's Working great'
    ^
    Casey@linux:~> su
    Password:
    linux:/home/Casey # ruby '/home/Casey/Desktop/testing.rb'
    /home/Casey/Desktop/testing.rb:1: syntax error, unexpected tIDENTIFIER, expecting $end
    puts 'Casey it's Working great'
    ^
    linux:/home/Casey #


    This is all i get

    Its supposed to say
    Its working great casey

    and then its supposed to wait until i hit enter

  8. #8
    Linux Guru gogalthorp's Avatar
    Join Date
    Oct 2006
    Location
    West (by God) Virginia
    Posts
    3,105
    Well this is a syntax error in any language. I Don't know ruby. But you are simply missing something. Maybe an include file??

    /home/Casey/Desktop/testing.rb:1: syntax error, unexpected tIDENTIFIER, expecting $end
    puts 'Casey it's Working great'
    ^

    This indicates there is a problem with this line. Is puts a command in Ruby?

    try
    $stdout.puts( "Casey it's Working great")

    In theory all puts commands should resolve to this. It appears some sort of preprocessing is happening.

    Note double quotes. Don't know if that is important but all examples I looked up had double not single quotes.

    In any case it appears you have it installed.

    This seems to be a good over view site.

    Programming Ruby: The Pragmatic Programmer's Guide

  9. #9
    Linux Guru gogalthorp's Avatar
    Join Date
    Oct 2006
    Location
    West (by God) Virginia
    Posts
    3,105
    Turns out I have ruby installed. Must have installed it via Yast at some time in the past. I tend to collect programmer stuff.

    Works here no problem. Did you install via Yast or smart. There is some mention of a rubyconf program that is supposed to set up the Ruby environment. Maybe you need to run that or install from a Suse repository like I apparently did.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...