get_system_command_output_1.sf 327 B

12345678910111213
  1. #!/usr/bin/ruby
  2. #
  3. ## https://rosettacode.org/wiki/Get_system_command_output
  4. #
  5. var pipe = %p(ls); # same as: Pipe.new('ls');
  6. var pipe_h = pipe.open_r; # open the pipe for reading
  7. var lines = []; # will store the lines of the output
  8. pipe_h.each { |line| lines.append(line.chomp) };
  9. say lines.len;