O'Reilly Forums: Trouble With Aws.rb - O'Reilly Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Trouble With Aws.rb

#1 User is offline   tenasakai 

  • New Member
  • Pip
  • Group: Members
  • Posts: 8
  • Joined: 01-July 09

Posted 01 July 2009 - 03:36 PM

Greetings,

I am trying to emulate what's on page 21 of the book, but I can't even get there. Maybe the code in AWS.rb is incompatible with the version of ruby I am using (ruby-1.9.1-p129)? Here's what the capture of my screen:

[tsakai@vixen ruby]$ irb
irb(main):001:0> require 'AWS'
SyntaxError: /home/tsakai/Notes/ec2/PAWS/PAWS_examples/ruby/AWS.rb:203: syntax error, unexpected ',', expecting tASSOC
...ww-form-urlencoded',{'charset', 'utf-8'})
... ^
/home/tsakai/Notes/ec2/PAWS/PAWS_examples/ruby/AWS.rb:203: syntax error, unexpected '}', expecting keyword_end
...rlencoded',{'charset', 'utf-8'})
... ^
/home/tsakai/Notes/ec2/PAWS/PAWS_examples/ruby/AWS.rb:474: syntax error, unexpected keyword_end, expecting $end
from (irb):1:in `require'
from (irb):1
from /usr/local/bin/irb:12:in `<main>'
irb(main):002:0> [tsakai@vixen ruby]$
[tsakai@vixen ruby]$

Regards,

Tena Sakai
0

#2 User is offline   JamesMurty 

  • Active Member
  • PipPip
  • Group: Members
  • Posts: 21
  • Joined: 20-March 08

Posted 01 July 2009 - 04:08 PM

Hi Tena Sakai,

That syntax error doesn't seem like it would be something caused by using a later version of Ruby. If it was a version incompatibility the program would mostly likely crash when it was run, not when it was first loaded.

Perhaps there is a structural problem in the code. Are you using the sample code that is available for download, or did you type it in from the book? If you typed it in, I would recommend downloading the code instead to avoid any problems with typos. You can get all the sample code here: http://examples.oreilly.com/9780596515812/

If you downloaded the code, that would make it more likely there is a Ruby version incompatibility. I just double-checked the sample code with Ruby 1.8.7 and was able to require 'AWS'. Are you able to test with an earlier version of Ruby?

James


0

#3 User is offline   tenasakai 

  • New Member
  • Pip
  • Group: Members
  • Posts: 8
  • Joined: 01-July 09

Posted 01 July 2009 - 04:22 PM

Thank you, James, for your reply.

I did downloaded the code from Oreilly website. (I am not a good enough typist to feel confident to retype your code!)

I have looked for an earlier version(s) of Ruby on the web (http://www.ruby-lang.org/en/downloads/ in particular), but it seems the only one available for linux platform is 1.9.1-p129.

If you have a source tree for Ruby 1.8.7, I would appreciate it if you could share it with me. If not, I am all ears as to what other suggestions you might have for me to move on.

Regards,

Tena Sakai


QUOTE (JamesMurty @ Jul 1 2009, 04:08 PM) <{POST_SNAPBACK}>
Hi Tena Sakai,

That syntax error doesn't seem like it would be something caused by using a later version of Ruby. If it was a version incompatibility the program would mostly likely crash when it was run, not when it was first loaded.

Perhaps there is a structural problem in the code. Are you using the sample code that is available for download, or did you type it in from the book? If you typed it in, I would recommend downloading the code instead to avoid any problems with typos. You can get all the sample code here: http://examples.oreilly.com/9780596515812/

If you downloaded the code, that would make it more likely there is a Ruby version incompatibility. I just double-checked the sample code with Ruby 1.8.7 and was able to require 'AWS'. Are you able to test with an earlier version of Ruby?

James


0

#4 User is offline   JamesMurty 

  • Active Member
  • PipPip
  • Group: Members
  • Posts: 21
  • Joined: 20-March 08

Posted 01 July 2009 - 04:38 PM

Hmm, I was hoping the issue would be related to a simple typo. That's a shame.

Unfortunately, Ruby isn't exactly renowned for maintaining backwards-compatibility.

The Ruby on Rails web has a link to a source tarball for 1.8.7, because this version is recommended for running Rails: http://rubyonrails.org/download

You don't mention which flavor of Linux you use, but if you are on Ubuntu this link describes how to install version 1.8 using apt-get:
http://www.rubyinside.com/how-to-install-a...ratch-1566.html

In short, you can specify which version of Ruby to install by using version-specific package names -- in the case of apt-get, these are ruby1.8 irb1.8 etc.

Hope this helps,
James

0

#5 User is offline   tenasakai 

  • New Member
  • Pip
  • Group: Members
  • Posts: 8
  • Joined: 01-July 09

Posted 01 July 2009 - 05:15 PM

Yeeeha!

I just compiled Ruby 1.8.7-p72 and ran it. The "require 'AWS'" command works!
Alas, my trouble is not quite over...

[tsakai@vixen ruby]$ irb
irb(main):001:0> require 'AWS'
=> true
irb(main):002:0> xml_text = File.new('example.xml','r').read
Errno::ENOENT: No such file or directory - example.xml
from (irb):2:in `initialize'
from (irb):2:in `new'
from (irb):2
irb(main):003:0>

It looks like now it is upset because it cannot find the file example.xml.
Is there any way I can not type this file in by hand? If you would post
it, they I can copy and paste into a file with such name.

I had neglected to mention my OS platform before. It is a redhat linux.
And there is nothing like ubuntu apt-bla command available. Since redhat's
package management system is so much a pain, I prefer to do everything
from source.

Regards,

Tena Sakai

PS: Maybe there should be a section in O'reilly's webpage where it says
Ruby 1.9.1 is to be avoided (in RED font)?



QUOTE (JamesMurty @ Jul 1 2009, 04:38 PM) <{POST_SNAPBACK}>
Hmm, I was hoping the issue would be related to a simple typo. That's a shame.

Unfortunately, Ruby isn't exactly renowned for maintaining backwards-compatibility.

The Ruby on Rails web has a link to a source tarball for 1.8.7, because this version is recommended for running Rails: http://rubyonrails.org/download

You don't mention which flavor of Linux you use, but if you are on Ubuntu this link describes how to install version 1.8 using apt-get:
http://www.rubyinside.com/how-to-install-a...ratch-1566.html

In short, you can specify which version of Ruby to install by using version-specific package names -- in the case of apt-get, these are ruby1.8 irb1.8 etc.

Hope this helps,
James


0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users