Here's my solution. I tried to make the most compact solution 
I could, based on my 2.5 months Ruby experience, so it may not 
be too pretty :)  Any comments are highly welcomed.

If the string is valid it outputs it and returns with exit code 0 
otherwise outputs nothing and returns with exit code 1

Have a nice day everyone,
Alex

__CODE__
OC,OK,ERR='([{)]}',0,1
i=ARGV[0];r=OK;s=[]
i.scan(/./) { |c| 
  next if (ci=OC.index(c)).nil?
  s.push OC[ci+3].chr if ci<3
  r=ERR if ci>2 and s.pop!=c 
}
r=ERR unless s.empty?
puts i if r==OK
exit r