Programming Amazon Web Services
Programming Amazon Web Services S3, EC2, SQS, FPS, and SimpleDB By James Murty
March 2008
Pages: 600


Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Trouble With Aws.rb
tenasakai
post Jul 1 2009, 03:36 PM
Post #1


New Member
*

Group: Members
Posts: 7
Joined: 1-July 09
Member No.: 18,967



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
Go to the top of the page
 
+Quote Post
JamesMurty
post Jul 1 2009, 04:08 PM
Post #2


Active Member
**

Group: Members
Posts: 20
Joined: 20-March 08
Member No.: 161



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

Go to the top of the page
 
+Quote Post
tenasakai
post Jul 1 2009, 04:22 PM
Post #3


New Member
*

Group: Members
Posts: 7
Joined: 1-July 09
Member No.: 18,967



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) *
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

Go to the top of the page
 
+Quote Post
JamesMurty
post Jul 1 2009, 04:38 PM
Post #4


Active Member
**

Group: Members
Posts: 20
Joined: 20-March 08
Member No.: 161



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
Go to the top of the page
 
+Quote Post
tenasakai
post Jul 1 2009, 05:15 PM
Post #5


New Member
*

Group: Members
Posts: 7
Joined: 1-July 09
Member No.: 18,967



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) *
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

Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

RSS Lo-Fi Version Time is now: 7th November 2009 - 06:57 PM