image
image

Go Back   macosx.com > Mac Help Forums > Unix & X11

Reply
 
Thread Tools
  #1  
Old April 29th, 2001, 01:42 AM
blb blb is offline
`'
 
Join Date: Apr 2001
Location: CO, USA
Posts: 651
Thanks: 0
Thanked 0 Times in 0 Posts
blb is on a distinguished road
Just found you can communicate (copy/paste) with the clipboard (or pasteboard) from the command line; most likely to be found useful in shell scripts...

The commands are pbcopy and pbpaste:

echo -n "copy this" | pbcopy

copies the string 'copy this' to the clipboard (the -n is to keep echo from adding a newline).

Simply running pbpaste will output what's in the clipboard.
Reply With Quote
  #2  
Old April 29th, 2001, 07:39 PM
marmoset's Avatar
Official Volunteer
 
Join Date: Sep 2000
Location: Ecorse, MI USA
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
marmoset is on a distinguished road
Quote:
Originally posted by blb
Just found you can communicate (copy/paste) with the clipboard (or pasteboard) from the command line; most likely to be found useful in shell scripts...
Cool! Sounds like that could be very useful
in conjunction with AEShell OSAX from
within Applescript as well...
__________________
iMac DV+ (Sage), 450MHz G3
512MB RAM, 20GB HD (ATA), DVD (ATA)
ProductName: Mac OS X
ProductVersion: 10.1.4
BuildVersion: 5Q125
Reply With Quote
  #3  
Old April 10th, 2003, 12:32 AM
deev's Avatar
Registered User
 
Join Date: Apr 2003
Location: Adelaide, Australia
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
deev is on a distinguished road
As useful as this command can be, I seem to be stuck with it. Whenever I start a new shell, it runs "pbpaste | sh" and if there happens to be some text in the clipboard, this will get pasted and executed, which generally generates a "command not found".

I have looked in (some of these files didn't exist for me):
/etc/csh.cshrc
/etc/csh.login
~/.tcshrc & ~/.tcshistory
~/.cshrc
~/.history
~/.login
~/.cshdirs

This particular command isn't in any of these files. Is there some way I can reset my Terminal back to "vanilla" or the likes? My apologies if this is the wrong place to post such a question!

Please help, this is very annoying.

deev
Reply With Quote
  #4  
Old April 10th, 2003, 10:04 AM
symphonix's Avatar
Scratch & Sniff Committee
 
Join Date: Jul 2001
Location: The Australian Jungles
Posts: 4,022
Thanks: 2
Thanked 2 Times in 2 Posts
symphonix is on a distinguished road
Deev: Have you checked the Terminal Preferences dialog? it is possible to set a command to be executed each time a term window opens by putting it here.
You might also delete the com.apple.Terminal.plist file from ~/Library/Preferences.

BLB: Thanks for the tip! That could make some really nifty shell script tricks that would be the envy of any Linux geek.
__________________
- iMac G5 1.8GHZ 17" | SuperDrive | 160GB | 512MB | Airport Extreme | Bluetooth Keyboard & Mouse | Wacom Intuos II
- Pentax *ist DL - JVC MiniDV Camcorder - Airport Express - iPod Nano 1gb white
Reply With Quote
  #5  
Old April 10th, 2003, 07:10 PM
deev's Avatar
Registered User
 
Join Date: Apr 2003
Location: Adelaide, Australia
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
deev is on a distinguished road
Quote:
Originally posted by symphonix
Deev: Have you checked the Terminal Preferences dialog? it is possible to set a command to be executed each time a term window opens by putting it here.
You might also delete the com.apple.Terminal.plist file from ~/Library/Preferences.
Cheers symphonix!! I checked the Preferences, but it was just set to the default. However, after deleting my .plist file the mysterious command was gone. Yay! All I had to do was reset my window settings (am a big fan of white on deep blue) and away I go!

I shoulda known it would be something simple (relatively!).

Thanks again,
deev
Reply With Quote
  #6  
Old April 12th, 2003, 11:54 AM
michaelsanford's Avatar
Psycholinguist
 
Join Date: Oct 2002
Location: Ottawa/Montrιal
Posts: 2,172
Thanks: 0
Thanked 0 Times in 0 Posts
michaelsanford is on a distinguished road
blb, that is way .

What happens, though, if someone logs in over SSH, who is not the same user as the one at the con, and tries pbpaste? Will it display the console's clipboard ?!
__________________
michaelsanford.com • Blog • Twitter • Tumblr • LinkedIn
• iMac Aluminum 24" |
MacOS X 10.5-current | 3.06 GHz Intel Core Duo | 4 GB RAM | 1 TB HDD
• iBook G4 1.42 GHz | MacOS X 10.5-current | 1 GB RAM, 100 GB HDD
• AMD Athlon64 3500+ | Slackware 12 (2.6.21.5-smp) | 2 GB RAM, 2•120 GB RAID 1, 2•500 GB RAID 0
Reply With Quote
  #7  
Old April 12th, 2003, 01:31 PM
TommyWillB's Avatar
Registered User
 
Join Date: Mar 2001
Location: ol' Gay San Francisco
Posts: 1,999
Thanks: 0
Thanked 0 Times in 0 Posts
TommyWillB is on a distinguished road
Picking up on what michaelsanford asked... I presume command line pbcopy & pbpaste are users specific?

So if I'm loggend in as me vs another user, will that will only affect that particular user?

If I login vi ssh and do this at the same time someone is on the Machine GUI could I screw with their paste board by doing this at the same time they are?

Are tehre security issues here?
__________________
TommyWillB
Intel iMac 250GB external drive
TommyWillB.com hosted on Mac OS X 10.4.x / Apache 1.3.x / PHP 4.x
Reply With Quote
  #8  
Old April 15th, 2003, 05:02 PM
Prescriptivist
 
Join Date: Sep 2000
Location: Behind you! Duck!
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
onan is on a distinguished road
Unfortunately, there is a single, globally readable and writable clipboard. Which is to say, yes, there is a huge security hole.

Unprivileged users can use tools like this to view whatever is on another user's (including root's) clipboard. Worse, another using writing anything to "their" clipboard will also change what all other users get.

Note that the problem isn't with pbcopy/pbpaste in particular, but rather the overall design of the clipboard service. Even if you remove these tools from your system, a user could create or install similar tools without needing any elevated privileges.

I've been complaining to Apple about this literally for years. This is one of a few issues which make macosx completely unsuitable as a production server platform in my mind.
__________________
The correct plural of forum is fora. _Please_ fix the painfully illiterate references to 'forums'.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Communicating between perl and FORTRAN. simX Mac OS X System & Mac Software 4 July 29th, 2002 06:48 AM
Not Going For Post Counts Only Communicating Appletree Bob's Place 1 June 1st, 2002 12:14 PM
Screen Shot to Clipboard Gedankenspiel Mac OS X System & Mac Software 3 February 21st, 2002 09:21 PM
global clipboard onan Mac OS X System & Mac Software 0 May 3rd, 2001 06:37 PM


All times are GMT -5. The time now is 07:53 AM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.