Finer Command Line Control?


#1

Is there any way to gain greater control of the command line in ruby? I
know it’s usually possible to send special characters to send the output
to a specific location, but I can’t seem to work it out.
Forgive me if I’m overlooking the obvious; Nuby here :slight_smile:

P.S. I’m on Windows. I imagine that could figure strongly here.


#2

Alexandru E. Ungur wrote:

For saving the output, you can simply redirect it to the desired
location using ‘>’, like this:

Sorry, my bad. When I said to a specific location I meant to a certain
area in the console, i.e. Overwriting output I’ve already sent. Is there
a way to do this in Ruby/Windows?


#3

sender: “Alex Barrett” date: “Sat, Apr 08, 2006 at 05:49:39PM +0900” <<<EOQ
Is there any way to gain greater control of the command line in ruby? I
know it’s usually possible to send special characters to send the output
to a specific location, but I can’t seem to work it out.
Forgive me if I’m overlooking the obvious; Nuby here :slight_smile:

P.S. I’m on Windows. I imagine that could figure strongly here.
Command line ‘belongs to’ the command interpreter not to Ruby, so what
you’re actually asking is ‘what can your windows commandline do’ for
you, right? :slight_smile:

For saving the output, you can simply redirect it to the desired
location using ‘>’, like this:

ruby.exe myscript.rb > c:\somefile.txt

More on redirection here (though UNIX specific, it does apply to windows
as well): http://en.wikipedia.org/wiki/Redirection_(Unix)

Good luck,
Alex


#4

Alex Barrett wrote:

Alexandru E. Ungur wrote:

For saving the output, you can simply redirect it to the desired
location using ‘>’, like this:

Sorry, my bad. When I said to a specific location I meant to a certain
area in the console, i.e. Overwriting output I’ve already sent. Is there
a way to do this in Ruby/Windows?

Such as printing a backspace character?

puts “\b”


#5

James B. wrote:

Such as printing a backspace character?

puts “\b”

Heh, thanks. So simple. It’s a bit cumbersome, but it’ll do.

Craig K. wrote:

Optionally, you can use the curses library if you don’t
want to embedded a bunch of escape sequences, which you will have to
figure out.

I’m on windows so no curses. At least, I get an error if I try :slight_smile:


#6

You will need to have ANSI terminal control sequences to place your
cursor
where you want. Optionally, you can use the curses library if you don’t
want to embedded a bunch of escape sequences, which you will have to
figure out.

On the other hand, if you wish to overwrite something on the same line,
you can use the backspace to back up to where you want and write what
you
want.

–Craig


#7

Alex Barrett wrote:

I’m on windows so no curses. At least, I get an error if I try :slight_smile:

In my efforts to get Diakonos running under Windows (without Cygwin), I
was able to get curses to go, so I can at least tell you it’s possible.
I don’t remember the details. That is, I don’t remember if the
one-click installer has it already, or if I had to download extra
material.

HTH;
Pistos


#8

On Sun, 2006-04-09 at 00:58 +0900, Alex Barrett wrote:

Craig K. wrote:

Optionally, you can use the curses library if you don’t
want to embedded a bunch of escape sequences, which you will have to
figure out.

I’m on windows so no curses. At least, I get an error if I try :slight_smile:

I remember last time I used DOS, you had to set up a device driver
(ANSI.SYS I believe) if you wanted to use ANSI terminal codes. If you
loaded that, you got the full set.

Oh, according to Wikipedia, Windows now has built in support, so you
could maybe try that…

http://en.wikipedia.org/wiki/ANSI_escape_code
http://rrbrandt.dyndns.org:60000/docs/tut/redes/ansi.php


#9

DÅ?a Sobota 8. Apríl 2006 17:58 Alex Barrett napísal:

I’m on windows so no curses. At least, I get an error if I try :slight_smile:

Hmm, aren’t you just missing the DLL? PDcurses should work in that case,
unless my memory fails me.

David V.