Skip to content

question about using a remote system

6 messages · Erin Hodgess, (Ted Harding), Mark Wardle +1 more

#
Dear R People:

I would like to set up a plug-in for Rcmdr to do the following:

I would start on a Linux laptop.  Then I would log into another
outside system and run a some commands.

Now, when I tried to do
system("ssh erin at xxx.edu")
password xxxxxx

It goes to the remote system.  how do I continue to issue commands
from the Linux laptop please?

(hope this makes sense)

thanks,
Erin
#
On 28-May-09 00:58:17, Erin Hodgess wrote:
Hi Erin,
If I understand what you want, I think you may be asking a bit
too much from R itself.

When you, Erin, are interacting with your Linux laptop you can
switch between two (or more) different X windows or consoles,
on one of which you are logged in to the remote machine and on
which you issue commands to the remote machine, and can read
its output and, maybe, copy this to a terminal running commands
on your Linux laptop.

When you ask R to log in as you describe, you are tying that
instance of R to the login. I don't know of any resources within
R itself which can emulate your personal behaviour. Though maybe
others do know ...

However, there is in principle a work-round. You will need to
get your toolbox out and get to grips with "Unix plmubing";
and, to make it accessible to R, you will need to create a
"Unix plumber".

The basic component is the FIFO, or "named pipe". To create
one of these, use a Linux command like

  mkfifo myFIFO1

Then 'ls -l' in the directory you are working in will show this
pipe as present with the name "myFIFO1". For example, if in one
terminal window [A] you start the command

  cat myFIFO1

then in another [B] you

  echo "Some text to test my FIFO" > myFIFO1

you will find that this text will be output in the [A] window
by the 'cat' command.

Similarly, you could 'mkfifo myFIFO2' and write tc this while
in the [A] window, and read from it while in the [B] window.

So, if you can get R to write to myFIFO1 (which is being read
from by another program which will send the output to a remote
machine which that program is logged into), and read from myFIFO2
which is being written to by that other program (and that is
easy to do in R, using connections), then you have the plumbing
set up.

But, to set it up, R needs to call in the plumber. In other words,
R needs to execute a command like

  system("MakeMyFIFOs")

where MakeMyFIFOs is a script that creates myFIFO1 and myFIFO2,
logs in to the remote machine, watches myFIFO1 and sends anything
it reads to the remote machine, watches for any feedback from
the remote machine and then writes this into myFIFO2.

Meanwhile, back in R, any time you want R to send something to
the remote machine you write() it (or similar) to myFIFO1, and
whenever you want to receive something from the remote machine
you readLines() it (or similar) from myFIFO2.

That's an outline of a possible work-round. Maybe other have solved
your same problem in a better way (and maybe there's an R package
which does just that ... ). If so, I hope they'll chip in!

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 28-May-09                                       Time: 07:33:09
------------------------------ XFMail ------------------------------
#
Hi.

Do you need an interactive session at the remote machine, or are you
simply wanting to run a pre-written script?

If the latter, then you can ask ssh to execute a remote command, which
conceivably could be "R CMD xxxxx"

If you explain exactly why and what you are trying to do, then perhaps
there's a better solution....

bw

Mark

2009/5/28 Erin Hodgess <erinm.hodgess at gmail.com>:

  
    
#
My goal is for a user to sit down at a Linux laptop, get to an Rcmdr
type screen, submit jobs on a remote system and then get the results
back in R.

We will assume that the user is naive, and the only thing he/she can
do is get to the Rcmdr screen.

The Rcmdr plugin will have a "submit jobs" menu.  The user presses
that option, and gets results, without having to know the "underside".

thanks,
Erin
On Thu, May 28, 2009 at 1:54 AM, Mark Wardle <mark at wardle.org> wrote:

  
    
#
Will R be able to send one batch of commands to the remote machine, then wait for the output?  Or will there be back and forth with new commands based on the output from the first commands?

You may want to look at the nws package for one way to have jobs run on a remote machine.
#
I've not ever tried something like this. You didn't quite answer the
question though. Do you need interactive sessions, or are users
choosing from a number of batch jobs?

If the latter, then perhaps you would be better forsaking Rcmdr (which
I have not used) and instead consider a shell-based, or web-based
interface (have you seen Rweb?). I presume by "job" you mean batch
jobs that are pre-written?

If you need an interactive session, then I can't see any easy way of
doing as you describe. I was waiting for someone else to suggest
something. My only suggestion would be to look at the unix program
"screen". You could then have a simple click-on application (shell
script or something) that connects to your remote system, runs screen,
gives them a prompt, and allows them to run arbitrary R interactive
sessions. For long-running tasks, they can then detach the screen and
leave it running on  the remote system.

I'm only guessing at your specific requirements here as I don't have
enough information about exactly you want to do!

Best wishes,

Mark



2009/5/28 Erin Hodgess <erinm.hodgess at gmail.com>: