This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Perl-OSX-Clipboard: Scripts to manipulate a Mac OS X-clipboard. | |
See: null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use IO::Socket::UNIX; | |
my $socket_file = shift || '/tmp/pb_server.pl.sock'; | |
my $connection = IO::Socket::UNIX->new( | |
Type => SOCK_STREAM, | |
Peer => $socket_file, | |
) or die $!; | |
my $data = ''; | |
my $read; | |
while ($connection->sysread($read, 1024)) { | |
$data .= $read; | |
} | |
print $data; | |
$connection->close; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use IO::Socket::UNIX; | |
my $socket_file = shift || '/tmp/pb_server.pl.sock'; | |
unlink $socket_file if -e $socket_file; | |
my $listen = IO::Socket::UNIX->new( | |
Type => SOCK_STREAM, | |
Local => $socket_file, | |
Listen => SOMAXCONN, | |
) or die $!; | |
while (my $connection = $listen->accept) { | |
open my $pbpaste, '-|', 'pbpaste' or next; | |
my $data; | |
{ | |
local $/; | |
$data = <$pbpaste>; | |
} | |
$connection->syswrite($data); | |
$connection->close; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment