Hello all,
I know you can get command line args using ARGV, but is there a way to use
the '<' operator to pipe data into your program, as in
ruby myprog.rb < ~/myfile.txt
···
--
James Coglan
Hello all,
I know you can get command line args using ARGV, but is there a way to use
the '<' operator to pipe data into your program, as in
ruby myprog.rb < ~/myfile.txt
--
James Coglan
I know you can get command line args using ARGV, but is there a way to use
the '<' operator to pipe data into your program, as in
AFAIK that's called I/O redirection.
ruby myprog.rb < ~/myfile.txt
$ ruby cat.rb < cat.rb
puts *ARGF
regards, Sandor Szücs
On 09.07.2008, at 09:22, James Coglan wrote:
--
Just read the IO $stdin, like:
$stdin.each { |line| puts "Found: #{line}" }
The < "operator" is a shell feature that will pass the content of a file to
the programs standard input (stdin).
martin
On Wednesday 09 July 2008 08:22:15 James Coglan wrote:
Hello all,
I know you can get command line args using ARGV, but is there a way to use
the '<' operator to pipe data into your program, as inruby myprog.rb < ~/myfile.txt
Maybe that's more readable, but my point wasn't the shell feature < .
cat.rb has one line:
puts *ARGF
$ ruby cat.rb < cat.rb
puts *ARGF
regards, Sandor Szücs
On 09.07.2008, at 14:34, Martin Boese wrote:
Just read the IO $stdin, like:
$stdin.each { |line| puts "Found: #{line}" }
The < "operator" is a shell feature that will pass the content of a file to
the programs standard input (stdin).
--
Thank you both. If anyone is the least bit interested I'm writing myself yet
another commandline option parser:
It's inspired by trollop, but it has some more option types and is more
easily extensible, automates a few extra things (like recognizing
--no-verbose if you've got a --verbose option for example) and it generates
slightly nicer (more man-page-like) help text.
2008/7/11 Sandor Szücs <sandor.szuecs@fu-berlin.de>:
On 09.07.2008, at 14:34, Martin Boese wrote:
Just read the IO $stdin, like:
$stdin.each { |line| puts "Found: #{line}" }
The < "operator" is a shell feature that will pass the content of a file
to
the programs standard input (stdin).Maybe that's more readable, but my point wasn't the shell feature < .
cat.rb has one line:
puts *ARGF
you may be interested in
http://codeforpeople.com/lib/ruby/main/main-2.8.1/README
http://codeforpeople.com/lib/ruby/main/main-2.8.1/samples/
gem install main
the whole concept is to obviate the notion of ever parsing options
cheers.
On Jul 11, 2008, at 10:59 AM, James Coglan wrote:
Thank you both. If anyone is the least bit interested I'm writing myself yet
another commandline option parser:GitHub - jcoglan/oyster: Command-line input parser that doesn't hate you
It's inspired by trollop, but it has some more option types and is more
easily extensible, automates a few extra things (like recognizing
--no-verbose if you've got a --verbose option for example) and it generates
slightly nicer (more man-page-like) help text.
--
we can deny everything, except that we have the possibility of being better. simply reflect on that.
h.h. the 14th dalai lama