Skip to content

Clipboard under Linux/Unix

3 messages · Philippe GROSJEAN, Brian Ripley, (Ted Harding)

#
Hello,

This may be a trivial question, but I don't find the answer in R online
help. Under Windows, I can copy/paste to the clipboard using
readClipboard()/writeClipboard(), or something like cat(..., file =
"clipboard"). Are there equivalent function for other platforms?
Best,

Philippe Grosjean

..............................................<??}))><........
 ) ) ) ) )
( ( ( ( (    Prof. Philippe Grosjean
 ) ) ) ) )
( ( ( ( (    Numerical Ecology of Aquatic Systems
 ) ) ) ) )   Mons-Hainaut University, Pentagone
( ( ( ( (    Academie Universitaire Wallonie-Bruxelles
 ) ) ) ) )   6, av du Champ de Mars, 7000 Mons, Belgium  
( ( ( ( (       
 ) ) ) ) )   phone: + 32.65.37.34.97, fax: + 32.65.37.33.12
( ( ( ( (    email: Philippe.Grosjean at umh.ac.be
 ) ) ) ) )      
( ( ( ( (    web:   http://www.umh.ac.be/~econum
 ) ) ) ) )
..............................................................
#
On Fri, 19 Nov 2004, Philippe Grosjean wrote:

            
No.  There is not necessarily even the equivalent of a clipboard; I am 
typing this in a terminal session on a remote computer that has no access 
to the clipboard on my local windowing system (nor even to my local 
display: for performance reasons the X11 connection is not forwarded, 
and even if it were, I do the same thing from my Windows laptop and 
there Exceed and Windows have separate clipboards in different formats).

Please do use R-devel and not R-help for programming questions: see the 
posting guide.
#
On 19-Nov-04 Philippe Grosjean wrote:
Hi Philippe,
Leaving aside the situation described by Brian, where the network
is set up to prevent it, normally in Unix/Linux running X windows
you could in certain circumstances (see below) do it transparantly
over the net between machines, as well as within the machine you
are working on, under program control.

Of course there is the usual "block-copy using mouse left button
and paste using mouse middle button" manoeuvre, but -- provided
you have WindowMaker installed (part of GNUstep, the NeXTstep
emulator; you don't need to be running WindowMaker, only to
have the relevant binaries available as /usr/X11R6/bin/wxcopy
and /usr/X11R6/bin/wxpaste) -- then there are also two commands
which put it under program control, especially useful for larger
blocks of text.

1. From 'man wxcopy':

wxcopy(1x)                                             wxcopy(1x)
NAME
       wxcopy - copy stdin or file into cutbuffer
SYNOPSIS
       wxcopy [options] [filename]
DESCRIPTION
       wxcopy  copies stdin or filename into the cutbuffer. If no
       cutbuffer is specified, the data will be copied into  cut-
       buffer 0 and the other cutbuffers will be rotated, if pre-
       sent.  If a cutbuffer is specified,  the  data  is  copied
       into  that  cutbuffer,  and no rotation of buffers is per-
       formed.

2. From 'man wxpaste':

wxpaste(1x)                                           wxpaste(1x)
NAME
       wxpaste - output a cutbuffer to stdout
SYNOPSIS
       wxpaste [options]
DESCRIPTION
       wxpaste outputs the contents of the specified cutbuffer to
       stdout. If no cutbuffer is specified, the cutbuffer 0 will
       be used as default.

(Read the man pages in full for information on the options, etc.)

Using these two commands, you should be able to write an R function
(using 'system()' function to invoke these commands) which does
what you want; you will probably need to exploit the Unix-type
redirection methods as well, e.g. to redirect stdout from 'wpaste'
as in

  wpaste > file.to.paste.into

As a trivial example:

  wxcopy < file1
  wxpaste > file2

Then file2 will contain a copy of the contents of file1.

To illustrate how it works (as typed in):
-----------------------------------------
wxcopy << EOT
This is something  
I want to copy into the cut buffer
and then
paste into the file
"mycopy"
EOT

wxpaste > mycopy

and this gives the contents of the file mycopy:
-----------------------------------------------
cat mycopy
This is something  
I want to copy into the cut buffer
and then
paste into the file
"mycopy"


Hoping this helps,
Ted.


--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861  [NB: New number!]
Date: 19-Nov-04                                       Time: 09:49:19
------------------------------ XFMail ------------------------------