F
Frank Hofmann
Hi all,
I'm working on an ssh script where I'd like to read out console
dimensions to adjust the output window - the default value of 80x24
isn't that good.
So I thought it should work by simply reading out the environment
variables $COLUMNS and $LINES (Linux system). The results in irb were
what I needed:
===---===---===---===---===---===
irb(main):001:0> ENV['COLUMNS']
=> "99"
irb(main):002:0> ENV['LINES']
=> "32"
===---===---===---===---===---===
But in a ruby script these things didn't work anymore. A really simple
script:
===---===---===---===---===---===
#!/usr/bin/ruby -w
puts ENV['USER']
puts ENV['LINES']
===---===---===---===---===---===
This gave me the output:
frank
nil
Ok, that didn't work like I've expected it, so here is another way:
===---===---===---===---===---===
irb(main):001:0> lines = `echo $LINES`
=> "32\n"
irb(main):002:0> puts lines
32
=> nil
===---===---===---===---===---===
Now as ruby script:
===---===---===---===---===---===
!/usr/bin/ruby -w
lines = `echo $LINES`
puts lines
===---===---===---===---===---===
Well, also no success. :-/ It gave me only a blank line.
Does anyone have an idea what I could do to get column & line numbers of
the console window?
Thanks...
Frank
I'm working on an ssh script where I'd like to read out console
dimensions to adjust the output window - the default value of 80x24
isn't that good.
So I thought it should work by simply reading out the environment
variables $COLUMNS and $LINES (Linux system). The results in irb were
what I needed:
===---===---===---===---===---===
irb(main):001:0> ENV['COLUMNS']
=> "99"
irb(main):002:0> ENV['LINES']
=> "32"
===---===---===---===---===---===
But in a ruby script these things didn't work anymore. A really simple
script:
===---===---===---===---===---===
#!/usr/bin/ruby -w
puts ENV['USER']
puts ENV['LINES']
===---===---===---===---===---===
This gave me the output:
frank
nil
Ok, that didn't work like I've expected it, so here is another way:
===---===---===---===---===---===
irb(main):001:0> lines = `echo $LINES`
=> "32\n"
irb(main):002:0> puts lines
32
=> nil
===---===---===---===---===---===
Now as ruby script:
===---===---===---===---===---===
!/usr/bin/ruby -w
lines = `echo $LINES`
puts lines
===---===---===---===---===---===
Well, also no success. :-/ It gave me only a blank line.
Does anyone have an idea what I could do to get column & line numbers of
the console window?
Thanks...
Frank