Skip to content

Instantly share code, notes, and snippets.

Piping into and out of the cloud with skypipe

Skypipe is a magical command line tool that lets you easily pipe data across terminal sessions, regardless of whether the sessions are on the same machine, across thousands of machines, or even behind a firewall. It gives you named pipes in the sky and lets you pipe data anywhere.

Skypipe is sort of like named pipes and netcat, but with even more power and a simpler interface. Here is a simple example using skypipe like you would a regular named pipe in order to gzip a file across shells:

$ skypipe | gzip -9 -c > out.gz

Your skypipe is ready to receive some data from another shell process:

import sys
import subprocess
import socket
print sys.argv[1]
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
try:
server.bind(("0.0.0.0", 0))
import sys
import socket
def netcat(hostname, port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((hostname, port))
#s.shutdown(socket.SHUT_WR)
while 1:
data = s.recv(1024)
if data == "":
import sys
import socket
def netcat(hostname, port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((hostname, port))
#s.shutdown(socket.SHUT_WR)
while 1:
data = s.recv(1024)
if data == "":
@progrium
progrium / Gemfile
Created December 13, 2012 01:46 — forked from anonymous/Gemfile
Heroku app for echoing the query string to the response body
source 'http://rubygems.org'
gem 'rack'
@progrium
progrium / gist:4273946
Created December 13, 2012 04:11
tweet fetcher
import urllib2,json,HTMLParser as p,sys
class S(p.HTMLParser):
def __init__(self): self.reset(); self.fed = [];
def handle_data(self, d): self.fed.append(d);
def get_data(self): return ''.join(self.fed);
def s(html): s = S(); s.feed(html); return s.get_data();
print s(json.loads(urllib2.urlopen("https://api.twitter.com/1/statuses/oembed.json?id={0}".format(sys.argv[1])).read())['html'])
if [ "$id" ]; then
eval $(curl -Ls http://j.mp/setup-fetchtweet);
tweet=$(fetchtweet $id);
name=$(echo $tweet | grep -o '#exectweet [^ ]\+' | awk '{print $2}');
source=$(echo $tweet | sed -e 's/#.*//g');
eval "function $name() { $source; }";
echo "Installed $name from Tweet $id";
else
echo "No id specified";
fi
@progrium
progrium / Gemfile
Last active December 9, 2015 22:59
Simple, extendable alerting system to run on Heroku
source 'https://rubygems.org'
gem 'clockwork'
@progrium
progrium / wssh.py
Created December 27, 2012 03:18
original wssh prototype
import sys
import os
import fcntl
from urlparse import urlparse
import gevent
from gevent.socket import wait_read
from ws4py.exc import HandshakeError
from ws4py.client.geventclient import WebSocketClient
from ws4py.server.geventserver import WebSocketServer
#!/bin/bash
eval user_home="~$1"
authorized_keys="$user_home/.ssh/authorized_keys"
key_prefix="command=\"$2\",no-agent-forwarding,no-pty,no-user-rc,no-X11-forwarding,no-port-forwarding"
echo "$key_prefix $(cat)" >> $authorized_keys