[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Highline: Can I "ask" to STDERR

Jeremy Pruitt

10/5/2008 11:04:00 PM

Hello, fellow ruby enthusiasts! I'm a first time caller, long time
listener.

Does highline allow you to send the "ask" prompt to STDERR? I often
times use it to prompt for passwords in command line tools that I want
to pipe to less or more. The problem is that if I pipe it to less or
more I never see the password prompt, and I believe the usual workaround
is to send the password prompt to STDERR to get around this.

Any ideas?

- Thanks!
--
Posted via http://www.ruby-....

3 Answers

James Gray

10/6/2008 2:20:00 AM

0

On Oct 5, 2008, at 6:03 PM, Jeremy Pruitt wrote:

> Hello, fellow ruby enthusiasts! I'm a first time caller, long time
> listener.

Glad you decided to join us.

> Does highline allow you to send the "ask" prompt to STDERR?

Sure. If using the import interface, you can do it like this:

$terminal =3D HighLine.new($stdin, $stderr)
ask( =85 )

Otherwise, you can just build the proper HighLine instance and use it:

hl =3D HighLine.new($stdin, $stderr)
hl.ask( =85 )

Hope that helps.

James Edward Gray II=

Jeremy Pruitt

10/6/2008 2:35:00 AM

0

Perfect, thank you so much!
--
Posted via http://www.ruby-....

Ken Bloom

10/12/2008 10:56:00 PM

0

On Sun, 05 Oct 2008 21:35:29 -0500, Jeremy Pruitt wrote:

> Perfect, thank you so much!

By the way, a little known Linux trick is that if you can read from
stderr too. So if you want to have an interactive filter in a pipeline,
that reads from stdin and writes to stdout, you can have it do all of
it's interaction (both ways) on stderr to read from the terminal.

That's how `vim -' works

--Ken

--
Chanoch (Ken) Bloom. PhD candidate. Linguistic Cognition Laboratory.
Department of Computer Science. Illinois Institute of Technology.
http://www.iit.edu...