Today sees a new release of Cliaws. This is a simple library to interact with S3 (and other services) through the command-line. This library is very similar to Amazon’s own ec2-* scripts, except this library is written in Ruby.

Interacting with S3 should be no harder than:


1 $ clis3 put my-local-file my-bucket/my-s3-file

Put many files at once:


1 $ clis3 put my-local-file0 my-local-file1 my-bucket/my-s3-directory/

Put an environment variable:


1 $ clis3 put —data $MY_DATA my-bucket/my-env-value

Put stdin too!


1 $ tar czfv /var/cache/mylvmbackup/backup | clis3 put – my-bucket/my-backup/backup-20080825-000000.tar.gz

All of this functionnality is available from with Ruby too:


1 require "rubygems"
2 require "cliaws"
3
4 Cliaws.s3.put("this is the content", "my-bucket/my-s3-file")
5 File.open("my-local-file", "rb") do |io|
6 Cliaws.s3.put(io, "my-bucket/my-s3-file")
7 end

Give the RubyForge gem servers a couple of hours to refresh themselves, and then enjoy!

I just pushed 1.2.0 to GitHub as well as RubyForge. This release has a single major improvement:


1 $ clis3 put A B local/C bucket/dir/
2 A => bucket/dir/A
3 B => bucket/dir/B
4 local/C => bucket/dir/C

put isn’t yet recursive, and note the caveat above: all paths are flattened to their basenames. Enjoy!

Links

Have you ever wished you could access your Amazon Simple Queue Service from the command line ? Now you can:


1 $ AWS_ACCESS_KEY_ID=<your access key>
2 $ AWS_SECRET_ACCESS_KEY="<the secret access key>"
3
4 $ clisqs create my-queue
5 Queue my-queue was created.
6
7 $ clisqs list
8 my-queue
9
10 $ clisqs push —data "this is the message" my-queue
11 Pushed 19 bytes to queue my-queue
12
13 $ cat README.txt | clisqs push my-queue
14 Pushed 2687 bytes to queue my-queue
15
16 $ clisqs push my-queue README.txt
17 Pushed 2687 bytes to queue my-queue
18
19 $ clisqs size my-queue
20 3
21
22 $ clisqs pop my-queue
23 this is the message
24
25 $ clisqs delete —force my-queue
26 Queue my-queue was deleted.

Installation


1 $ sudo gem install cliaws

Direct-code access


1 require "rubygems"
2 require "cliaws"
3
4 Cliaws.sqs.push("my-queue", "the data")
5 the_size = Cliaws.sqs.size("my-queue")
6 the_message = Cliaws.sqs.pop("my-queue")

S3 ?

This gem also works with S3. See my prior release announcement: Cliaws: command-line access to S3

I just released a new gem on RubyForge: cliaws. Using it, you have access to nice command line shortcuts:


1 $ AWS_ACCESS_KEY_ID=<your access key>
2 $ AWS_SECRET_ACCESS_KEY="<the secret access key>"
3 $ clis3 list BUCKET/PATH-PREFIX
4 $ clis3 put BUCKET/FULL/PATH/NAME /path/to/local/file
5 $ clis3 get BUCKET/FULL/PATH/NAME /path/to/local/file
6 $ clis3 cat BUCKET/FULL/PATH/NAME

This is not rocket science, but with the kind of work I’m doing at the moment, having quick command-line access to S3 is a boon.

Installation


1 $ gem install cliaws

Direct-code access


1 require "rubygems"
2 require "cliaws"
3
4 # Retrieve and store in a variable
5 value = Cliaws.s3.get("BUCKET/FULL/PATH/NAME")
6
7 # Retrieve and stream to specified file
8 File.open("/path/to/local/file", "w") do |f|
9 Cliaws.s3.get("BUCKET/FULL/PATH/NAME", f)
10 end
11
12 # Returns an Array of full names
13 contents = Cliaws.s3.list("BUCKET")

Repository

The repository is hosted on GitHub, with a mirror on RubyForge.

The repository’s URLs are:

Go forth and fork !

Search

Your Host

A picture of me

I am François Beausoleil, a Ruby on Rails and Scala developer. During the day, I work on Seevibes, a platform to measure social interactions related to TV shows. At night, I am interested many things. Read my biography.

Top Tags

Books I read and recommend

Links

Projects I work on

Projects I worked on