Forum: Ruby Finer Command Line Control?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E2148159cc245f2335bb9f333c5ce449?d=identicon&s=25 Alex Barrett (Guest)
on 2006-04-08 10:49
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 :)

P.S. I'm on Windows. I imagine that could figure strongly here.
245cfab887781bdf3f53178b794c42dc?d=identicon&s=25 Alexandru E. Ungur (Guest)
on 2006-04-08 12:07
(Received via mailing list)
>>> 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 :)
>
> 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? :)

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_%28Unix%29


Good luck,
Alex
E2148159cc245f2335bb9f333c5ce449?d=identicon&s=25 Alex Barrett (Guest)
on 2006-04-08 12:52
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?
Bc6d88907ce09158581fbb9b469a35a3?d=identicon&s=25 James Britt (Guest)
on 2006-04-08 16:48
(Received via mailing list)
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"
B81659fa35f4cf2da37bca8664ffc7d0?d=identicon&s=25 Craig Kim (Guest)
on 2006-04-08 16:54
(Received via mailing list)
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
E2148159cc245f2335bb9f333c5ce449?d=identicon&s=25 Alex Barrett (Guest)
on 2006-04-08 17:58
James Britt wrote:
> Such as printing a backspace character?
>
> puts "\b"

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

Craig Kim 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 :)
A9b6a93b860020caf9d2d1d58c32478f?d=identicon&s=25 Ross Bamford (Guest)
on 2006-04-08 20:35
(Received via mailing list)
On Sun, 2006-04-09 at 00:58 +0900, Alex Barrett wrote:
> Craig Kim 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 :)
>

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
A402df36168b81b31c17adcbb5ae8cf4?d=identicon&s=25 Pistos Christou (pistos)
on 2006-04-09 03:44
Alex Barrett wrote:
> I'm on windows so no curses. At least, I get an error if I try :)

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
430ea1cba106cc65b7687d66e9df4f06?d=identicon&s=25 David Vallner (Guest)
on 2006-04-09 06:16
(Received via mailing list)
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 :)
>

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

David Vallner
This topic is locked and can not be replied to.