[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Fairly elementary UNIX question

Steckly, Ron

12/23/2007 6:22:00 AM

Hi,

=20

I've been learning a lot about the .NET architecture and scripting to it
using Visual Basic and C#. I'm trying to write a program right now in
UNIX and I'm a little perplexed. How do I tap into events in UNIX? For
example, if I were to write a script to enter a command into the R
Statistics Program running in Linux, how would I do that?=20

Normally, in bash I would type R

And a new prompt comes up and you can type whatever command you want.

I'd like to be able to make a simple GUi for it so that its easier for
people to enter commands who are still learning R. But I'm not sure how
to script to a terminal....

=20

Am I completely on the wrong track?

=20

Ron


6 Answers

Sebastian Hungerecker

12/23/2007 8:41:00 AM

0

Steckly, Ron wrote:
> I'd like to be able to make a simple GUi for [R] so that its easier for
> people to enter commands who are still learning R. =A0But I'm not sure how
> to script to a terminal....

"script to a terminal" is maybe the wrong term, because there is no termina=
l=20
involved at all (at least no xterm). You want pipes:

require 'open3'
input, output, errors =3D Open3.popen3("R")
input.puts "my_command"
response =3D output.gets
=2E..


HTH,
Sebastian
=2D-=20
Jabber: sepp2k@jabber.org
ICQ: 205544826

Ken Bloom

12/23/2007 6:57:00 PM

0

Steckly, Ron <rsteckly@wharton.upenn.edu> wrote:
> I've been learning a lot about the .NET architecture and scripting to it
> using Visual Basic and C#. I'm trying to write a program right now in
> UNIX and I'm a little perplexed. How do I tap into events in UNIX? For
> example, if I were to write a script to enter a command into the R
> Statistics Program running in Linux, how would I do that?
>
> Normally, in bash I would type R
>
> And a new prompt comes up and you can type whatever command you want.
>
> I'd like to be able to make a simple GUi for it so that its easier for
> people to enter commands who are still learning R. But I'm not sure how
> to script to a terminal....
>
> Am I completely on the wrong track?

On UNIX, terminal programs simply have a few open pipes (which behave
like files) by default, the standard input, standard output, and
standard error. When you start a new program, the calling program is
given the other end of each of those pipes. (It's a little more
complicated, but various ruby libraries abstract away the compliation
and make this process appear exactly as I said it.) When a program
runs in a terminal on UNIX, the terminal is the calling process. All
the terinal does is display the data that's written to stdout and
stderr, and takes keyboard input and sends it to stdin. When
Ruby calls a program, Ruby is the calling process, and you can use the
pipes however you want. You can get access to the pipes by using popen
(built-in) or the Open3 or Open4 libraries.

Note that if you want the output of R to appear on Ruby's calling
terminal, you have to do a little work to put the output there
yourself.

--Ken

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

Robert Klemme

12/23/2007 7:50:00 PM

0

On 23.12.2007 19:57, Ken Bloom wrote:
> Steckly, Ron <rsteckly@wharton.upenn.edu> wrote:
>> I've been learning a lot about the .NET architecture and scripting to it
>> using Visual Basic and C#. I'm trying to write a program right now in
>> UNIX and I'm a little perplexed. How do I tap into events in UNIX? For
>> example, if I were to write a script to enter a command into the R
>> Statistics Program running in Linux, how would I do that?
>>
>> Normally, in bash I would type R
>>
>> And a new prompt comes up and you can type whatever command you want.
>>
>> I'd like to be able to make a simple GUi for it so that its easier for
>> people to enter commands who are still learning R. But I'm not sure how
>> to script to a terminal....
>>
>> Am I completely on the wrong track?
>
> On UNIX, terminal programs simply have a few open pipes (which behave
> like files) by default, the standard input, standard output, and
> standard error. When you start a new program, the calling program is
> given the other end of each of those pipes. (It's a little more
> complicated, but various ruby libraries abstract away the compliation
> and make this process appear exactly as I said it.) When a program
> runs in a terminal on UNIX, the terminal is the calling process. All
> the terinal does is display the data that's written to stdout and
> stderr, and takes keyboard input and sends it to stdin. When
> Ruby calls a program, Ruby is the calling process, and you can use the
> pipes however you want. You can get access to the pipes by using popen
> (built-in) or the Open3 or Open4 libraries.
>
> Note that if you want the output of R to appear on Ruby's calling
> terminal, you have to do a little work to put the output there
> yourself.

Sorry to nitpick, but if you start a program from the shell without a
pipeline and any redirections , stdout, stderr and stdin are not
connected to pipes but to devices of the terminal. (This is also true
for the shell's own file descriptors 0, 1 and 2.)

Kind regards

robert

M. Edward (Ed) Borasky

12/23/2007 8:07:00 PM

0

Steckly, Ron wrote:
> Hi,
>
>
>
> I've been learning a lot about the .NET architecture and scripting to it
> using Visual Basic and C#. I'm trying to write a program right now in
> UNIX and I'm a little perplexed. How do I tap into events in UNIX? For
> example, if I were to write a script to enter a command into the R
> Statistics Program running in Linux, how would I do that?
>
> Normally, in bash I would type R
>
> And a new prompt comes up and you can type whatever command you want.
>
> I'd like to be able to make a simple GUi for it so that its easier for
> people to enter commands who are still learning R. But I'm not sure how
> to script to a terminal....
>
>
>
> Am I completely on the wrong track?

Well ... not so much on the wrong track as on the wrong mailing list. :)
But since I'm an R programmer, I'll give you the R answer. :)

1. On *Windows*, there is an excellent GUI/IDE available for the
language -- the base Windows R installation.

2. There is a mailing list devoted to R GUI packages, which is at
https://stat.ethz.ch/mailman/listinfo...

3. In terms of learning R from a GUI, I highly recommend the R Commander
library. Assuming you want to make this available to other users or you
have R installed at the system level, become root, start up R and type

> install.packages("Rcmdr", depend=c("Depends", "Suggests", "Imports"))

You'll need the Tcl/Tk stuff in R for this to work, so if your R doesn't
have that, you'll need to rebuild it. Note that the above will also work
on the Windows R!!

4. Now you have R Commander installed. At the R prompt, type

> library(Rcmdr)

This brings up the GUI. What's nice about R Commander is that it allows
you to capture the script and its output from everything you've done. In
addition, if you drag in all the dependencies, you get some of the more
convenient functionality like scatterplot matrices, etc., built in.

I should note that the philosophy of R (and its ancestor S) it that it
*is* a programming language, and even if you do have a "fancy GUI" like
SPSS or Minitab, that's only a "crutch" until you learn to program in
the language.

Now, if you're an experienced Ruby GUI programmer and want to build your
own, there's an R - Ruby bridge called "rsruby", which I think is in the
RubyGems repository. It's a little tricky to install -- some Linux
distros don't put things in exactly the right place. But once you get it
installed, a Ruby program can interact with R without all the "shell and
pipe nonsense". :)


M. Edward (Ed) Borasky

12/23/2007 8:13:00 PM

0

M. Edward (Ed) Borasky wrote:
> Steckly, Ron wrote:
>> Hi,
>>
>>
>>
>> I've been learning a lot about the .NET architecture and scripting to it
>> using Visual Basic and C#. I'm trying to write a program right now in
>> UNIX and I'm a little perplexed. How do I tap into events in UNIX? For
>> example, if I were to write a script to enter a command into the R
>> Statistics Program running in Linux, how would I do that?
>>
>> Normally, in bash I would type R
>>
>> And a new prompt comes up and you can type whatever command you want.
>>
>> I'd like to be able to make a simple GUi for it so that its easier for
>> people to enter commands who are still learning R. But I'm not sure how
>> to script to a terminal....
>>
>>
>>
>> Am I completely on the wrong track?
>
> Well ... not so much on the wrong track as on the wrong mailing list. :)
> But since I'm an R programmer, I'll give you the R answer. :)
>
> 1. On *Windows*, there is an excellent GUI/IDE available for the
> language -- the base Windows R installation.
>
> 2. There is a mailing list devoted to R GUI packages, which is at
> https://stat.ethz.ch/mailman/listinfo...
>
> 3. In terms of learning R from a GUI, I highly recommend the R Commander
> library. Assuming you want to make this available to other users or you
> have R installed at the system level, become root, start up R and type
>
>> install.packages("Rcmdr", depend=c("Depends", "Suggests", "Imports"))
>
> You'll need the Tcl/Tk stuff in R for this to work, so if your R doesn't
> have that, you'll need to rebuild it. Note that the above will also work
> on the Windows R!!
>
> 4. Now you have R Commander installed. At the R prompt, type
>
>> library(Rcmdr)
>
> This brings up the GUI. What's nice about R Commander is that it allows
> you to capture the script and its output from everything you've done. In
> addition, if you drag in all the dependencies, you get some of the more
> convenient functionality like scatterplot matrices, etc., built in.
>
> I should note that the philosophy of R (and its ancestor S) it that it
> *is* a programming language, and even if you do have a "fancy GUI" like
> SPSS or Minitab, that's only a "crutch" until you learn to program in
> the language.
>
> Now, if you're an experienced Ruby GUI programmer and want to build your
> own, there's an R - Ruby bridge called "rsruby", which I think is in the
> RubyGems repository. It's a little tricky to install -- some Linux
> distros don't put things in exactly the right place. But once you get it
> installed, a Ruby program can interact with R without all the "shell and
> pipe nonsense". :)
>
>
>

P.S.: I just did this on my system and there's a dependency on
"unixODBC" on a Linux box. On a Windows system, ODBC is already there. :)

Mr. B1ack

2/21/2014 2:37:00 AM

0

On Thu, 20 Feb 2014 11:37:25 -0700, suzeeq <suzee@imbris.com> wrote:

>Mr. B1ack wrote:
>> On Thu, 20 Feb 2014 04:10:00 +0100 (CET), "Modern Marvels - Making
>> Queers" <chem-fags@msnbc.com> wrote:
>>
>>> Chemicals in plastics alter the brains of baby boys, making them
>>> "more feminine", say US researchers.
>>
>> But the girls come out kick-ass ! :-)
>>
>
>No they hit puberty sooner, like at 8 or 9. The plastics make a faux
>estrogen.

I guess since the boys are stunted they
all have to become radical lesbian
feminists ? Clearly these plastics are
a longstanding plot by the N.O.W. !!!

Alas I see very little "feminization" of
young American manhood. The level
of violence alone suggests an abundance
of testosterone.

I think your researchers have confused
"could cause" with "does cause".

Any wimpification of America is not being
caused by plastic, it is being caused by
tofu-sucking ultraliberals.