I use a command line twitter client, TTYtter, thru PuTTY on a linux box. Lots of tweets contain links, so there's a /url command to open urls, which searches for URLs a in a given tweet and runs a command on them locally to launch a browser with that url (e.g. open %U on mac or firefox -new-tab %U on Linux).

My question: Is there a command I can run from within a PuTTY session to open a URL in my local (windows 7) machine? To put it another way: is there a way, from within an SSH session in PuTTY, to reach out of the SSH session to the local machine?

EDIT: Another approach: Is there any combination of PuTTY and a windows ssh daemon or cygwin or something that I could use to ssh to my local box (loopback) and trigger a tab to open? I use tmux for multiplexing so my goal is to have all my stuff in one putty window.


PuTTY doesn't support the launching of local applications unless of course you are connected via SSH to the local machine. One option is to install Cygwin on your Windows box and install TTYtter on there. Essentially TTYtter is a collection of Perl scripts and should work fine on Cygwin assuming you have Perl installed as well.

  • Furthermore, if you use Cygwin's mintty terminal, you can just Ctrl+click on a link to open it in your default browser. – ak2 Sep 7 '11 at 14:23

So this probably doesn't work in a lot of cases, but here's what I came up with:

  1. Run a service on the host machine that listens for incoming URLs.

    I used NodeJS here for no particular reason; I'm sure most popular scripting languages would work.

    var http = require('http'),
      querystring = require('querystring'),
      cp = require('child_process'),
      ip = '',
      port = 9090,
      links_opened = 0;
      //urlopen curl --data "url=%U" %U  <- cmd for ttytter
    http.createServer(function (req, res) {
      if (req.method == 'POST') {
        req.on('data', function(chunk) {
      //get URL
          var _post = querystring.parse(chunk.toString()),
          //url has extra quotes for some reason:
            url_to_open = _post.url.match(/^'(.*)'$/)[1],
          //these three lines are just for nicely numbered console history (up to 999)
            link_ind = ++links_opened + ".",
            ln = link_ind + Array(5 - link_ind.length).join(' ');//pad it
            console.log( ln + url_to_open);
      //open tab
          cp.spawn('c:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe', ['-new-tab', url_to_open]);
      req.on('end', function() {
        //respond w/204 (success, no output)
    }).listen(port, ip);
    console.log('Server running at http://' + ip + ":" + port);
  2. Send URLs from the host to the guest (I used cURL).

    In my .ttytterrc, I define the urlopen option thus: urlopen curl --data "url=%U" %U (%U is expanded to the URL: see urlopen).

I call /url <tweet ID>, it sends a request to my host machine, and the node service opens a new tab in my current browser window. I'm sure there are a host of potential security issues here, but given proper firewall settings, IP checks in the nodeJS script, etc., these are not showstoppers. Anyway, it works for me!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.