bin/ec2sh in amazon-ec2-0.3.2 vs bin/ec2sh in amazon-ec2-0.3.4
- old
+ new
@@ -7,66 +7,55 @@
# Copyright:: Copyright (c) 2007-2008 Glenn Rempe
# License:: Distributes under the same terms as Ruby
# Home:: http://github.com/grempe/amazon-ec2/tree/master
#++
-# CREDITS : Credit for this bit of shameful ripoff coolness
+# CREDITS : Credit for this bit of shameful ripoff coolness
# goes to Marcel Molina and his AWS::S3 gem. Thanks!
-# Usage : running this starts up an irb session and
+# Usage : running this starts up an irb session and
# sets up the connection to EC2 as a class variable called
-# '@ec2'. So just do something like the following on the
+# '@ec2'. So just do something like the following on the
# shell command line:
-# macbook-pro:~ glenn$ ec2sh
+# macbook-pro:~ glenn$ ec2sh
# >> @ec2.describe_images
# => [#<EC2::Item image_location...
ec2_lib = File.dirname(__FILE__) + '/../lib/EC2'
setup = File.dirname(__FILE__) + '/setup'
irb_name = RUBY_PLATFORM =~ /mswin32/ ? 'irb.bat' : 'irb'
if ( ENV['AMAZON_ACCESS_KEY_ID'] && ENV['AMAZON_SECRET_ACCESS_KEY'] )
-
+
welcome_message = <<-MESSAGE
-
+
'ec2sh' usage :
- This is an interactive 'irb' command shell that allows you to use all
+ This is an interactive 'irb' command shell that allows you to use all
commands available to the amazon-ec2 gem. You'll find this to be a
great tool to help you debug issues and practice running commands
against the live EC2 servers prior to putting them in your code.
-
- The EC2 connection is wired to the class instance '@ec2'. Make method calls
- on this to execute commands on EC2. Adding a #to_s
+
+ The EC2 connection is wired to the class instance '@ec2'. Make method calls
+ on this to execute commands on EC2. Adding a #to_s
at the end of any command should give you a full String representation of the
- response. The #xml data is available for each response
- which allows you to view the full and complete XML response returned by
- EC2 without any parsing applied. This is useful for viewing the
- hierarchy of an entire response in a friendly way (if XML is friendly
- to you!). Understanding the hierarchy of the XML response is critical
- to making effective use of this library.
-
+ response.
+
Examples to try:
-
+
returns : all ec2 public methods
>> @ec2.methods.sort
-
+
returns : a string representation of ALL images
>> @ec2.describe_images.to_s
-
+
returns : an Array of EC2::Response objects, each an EC2 image and its data
>> @ec2.describe_images.imagesSet.item
>> @ec2.describe_images.imagesSet.item[0] (an OpenStruct of a single item in that array)
>> @ec2.describe_images.imagesSet.item[0].to_s (a String representation of that OpenStruct item)
-
- returns : an XML representation of all images
- >> puts @ec2.describe_images.xml
-
- returns : an XML representation of all images owned by Amazon
- >> puts @ec2.describe_images(:owner_id => 'amazon').xml
-
+
MESSAGE
-
+
puts welcome_message
exec "#{irb_name} -r #{ec2_lib} -r #{setup} --simple-prompt"
else
puts "You must define AMAZON_ACCESS_KEY_ID and AMAZON_SECRET_ACCESS_KEY as shell environment variables before running #{$0}!"
end
\ No newline at end of file