Wormhole

While developing tools for StratOS, I wrote a nifty little program that I call "Wormhole," which uses the Linux kernel's inotify functionality to respond to filesystem events. More specifically, it watches a single directory and performs specified actions on any files that are moved into or written to the directory. Once the files are processed, the results are stored in another directory. The syntax is like this:

$ wormhole action entrance_directory exit_directory
where the action is either a program name or one of the built-in commands: --zip or --unzip. The program that is used as the action, must take two input arguments: an input file and an output directory. Wormhole expects the action to remove the input file from the entrance_directory as its final step. The simplest (very silly) example is:
$ wormhole mv /directory1/  /directory2/
In this example, the action is the move command, mv. Whenever a file is added to /directory1, it will automatically be moved to /directory2.

A more realistic use case would involve a script that performs some sort of useful operations on the files that enter the entrance_directory. Here's a slightly less silly example action:

#! /bin/bash

# pdf_append.sh - A command for adding new pages to a PDF file
# usage: pdf_append.sh input_image output_directory
# where input_image is an image file that can be processed with
# ImageMagick's convert command and output_directory contains
# exactly one PDF document.
# Note that this is a very fragile script for demonstration
# purposes only.

input_image=$1
output_dir=$2

# convert image to PDF 
# (this assumes the input isn't already a PDF)

input_pdf="$input_image.pdf"
convert $input_image $input_pdf

# get the name of the PDF being appended to.
# assumes there is exactly one PDF file in output_dir 

output_pdf="$(ls $output_dir/*.pdf)"

temp_pdf="${output_pdf/.pdf/-temp.pdf}"

# append the input_pdf to the end of the output_pdf

mv $output_pdf $temp_pdf

pdfunite $temp_pdf $input_pdf $output_pdf
# these tools would also work: 
# pdftk $temp_pdf $input_pdf cat output $output_pdf 
# pdfjoin $temp_pdf $input_pdf $output_pdf

# delete intermediate files:

rm $input_image $input_pdf $temp_pdf

Suppose I create directories in my current working direcotry, called in/ and out/. Inside of the out/ directory, I place a PDF document. I then execute wormhole, like this:
$ wormhole ./pdf_append.sh in out 
Now, if I save or move images into the in/ directory, they will automatically be appended to the PDF document in out/ as new pages.

Wormhole was initially developed to provide a means of automatically compressing and decompressing files before they are sent over a non-compressed network stream (specifically, NFS), so it has two built-in actions, --zip and --unzip. These actions currently use zlib to perform the compression, but they will eventually use the LZO compression library, due to its compression speed. The input and output directories are in RAM-backed, tmpfs file systems in order to minimize latency. The sender places files into one "mouth" of the wormhole and files are compressed and sent to the destination computer. The receiver watches the other mouth of the worm hole and decompresses files as they arrive.

The current version of Wormhole isn't written to be a proper daemon, but it can be cheaply "daemonized" using nohup and output redirection. For example:

$ nohup wormhole --zip /path/to/in /path/to/out 1> /dev/null 2>/dev/null &
The source for the version of Wormhole described above can be found here.

61 Responses to “Wormhole”

  1. lenalawr Says:

    Hello everyone, it’s Lena Lawrence here!
    I work as a professional an essay writer and have created this content with the intent of changing your life for the better. I started honing my writing abilities in my school years. I learned that my fellow students needed writing help—and they were willing to pay for it. The money was enough to help pay my tuition for my first semester of college.
    Ever since high school, I have continued to work as an academic writer. I was hired by a writing company based in the United Kingdom. Since then, the research papers that I have created have been sold around Europe and the United States.
    In my line of work, I have become familiar with hearing, “Lena, can you help me meet my writing assignment deadline?” I know that I can provide this service.

    Professional Writer – Lena – Speech writing services can help in personal branding Confederation

  2. joannab Says:

    My name is Joanna. And I am a professional Content writer with many years of experience in writing.

    My goal is to solve problems related to writing. And I have been doing it for many years. I have been with several organizations as a volunteer and have assisted in many ways.
    My love for writing has no end. It is like the air we breathe, something I cherish with all my being. I am a passionate writer who started at an early age.
    I’m happy that I`ve already sold several copies of my books in different countries like USA, Russia and others too numerous to mention.
    I also work in an organization that provides assistance to many people from different parts of the world. Students always come to me because I work no matter how hard their projects are. I help them to save energy, because I feel happy when people come to me for writing help.

    Professional academic Writer – Joanna - www.screenwritermag.com/ - Screenwritermag Confederation

  3. katrinamer Says:

    Good day and welcome to my website . I’m Katrina.
    I have always dreamed of being a book writer but never dreamed I’d make a career of it. In college, though, I helped a fellow student who needed help. She could not stop complimenting me . Word got around and someone asked me for to write their paper just a week later. This time they would compensate me for my work.
    During the summer, I started doing research papers for students at the local college. It helped me have fun that summer and even funded some of my college tuition. Today, I still offer my writing services to students.

    Professional Writer – Katrina – Soundgardenkinganimal Band

  4. paulinahop Says:

    My name is Paulina. And I am a professional academic writer with many years of experience in writing.

    My goal is to solve problems related to writing. And I have been doing it for many years. I have been with several organizations as a volunteer and have assisted people in many ways.
    My love for writing has no end. It is like the air we breathe, something I cherish with all my being. I am a passionate writer who started at an early age.
    I’m happy that I`ve already sold several copies of my books in different countries like England and others too numerous to mention.
    I also work in a company that provides assistance to many students from different parts of the world. Clients always come to me because I work no matter how hard their projects are. I help them to save time, because I feel happy when people come to me for writing help.

    Professional academic Writer – Paulina - Tutoronwheelsef Band

  5. janawood Says:

    I’m an expert writer who loves to bring smiles to people's face.

    Writing is what I do for a living and I am so passionate about this. I have worked with several companies whose mission is to help people solve writing problems.
    I love traveling and have visited several places in the past few years.
    I’m happy to have written several books that have contributed positively to the lives of many. My works are available in several parts of the world. And I’m currently working with companies that help people save time. Being a part of this team has open more opportunities for me to excel as a writer. I have worked with different people and met many clients as a professional.
    I can handle any kind of writing and provide nothing but the best. People come to me all the time to ask if I can solve their assignment problems and I accept. I find pleasure in assisting them to solve their problems as a professional.

    Professional Writer – Jana Woods - Csnbiologyclub Corp

  6. emmet Says:

    My name is Emmett. And I am a professional academic writer with many years of experience in writing.

    My primary goal is to solve problems related to writing. And I have been doing it for many years. I have been with several associations as a volunteer and have assisted people in many ways.
    My love for writing has no end. It is like the air we breathe, something I cherish with all my being. I am a passionate writer who started at an early age.
    I’m happy that I`ve already sold several copies of my poems in different countries like USA, Russia and others too numerous to mention.
    I also work in an organization that provides assistance to many people from different parts of the world. Students always come to me because I work no matter how difficult their projects are. I help them to save energy, because I feel fulfilled when people come to me for professional help.

    Ghost Writer – Emmett - //www.sodobusinessassociation.org/]SodobusinessassociationCorp

  7. beverle Says:

    I’m an expert writer who loves to bring smiles to people's face.

    Writing is what I do for a living and I am so passionate about this. I have worked with several companies whose goal is to help people solve writing problems.
    I love traveling and have visited several countries in the past few years.
    I’m happy to have written several books that have contributed positively to the lives of many. My works are available in several parts of the world. And I’m currently working with companies that help people save time. Being a part of this team has open more opportunities for me to excel as a writer. I have worked with different people and met many clients as a professional.
    I can handle any kind of writing and provide nothing but the best. People come to me all the time to ask if I can solve their writing problems and I accept. I find pleasure in helping them to solve their problems as a professional.

    Professional Academic Writer – Beverley Harmon - //www.greenadviser.org/]GreenadviserTeam

  8. wilson Says:

    Hi, my name is Wilson!

    I`m a professional writer and I`m going to change your lifes on?e and for all
    Writing has been my passion for a long time and now I can`t imagine my life without it.
    Most of my poems were sold throughout Canada, USA, Old England and even India. Also I`m working with services that help people to save their nerves.
    People ask me "Mr, Wilson Wheeler, I need your professional help" and I always accept the request, `cause I know, that only I can solve all their problems!

    Professional Academic Writer - Wilson - //www.quibblo.com/user/BronwynL]BronwynLeigh Confederation

  9. liam Says:

    Hey, I am Liam Scott a professional in report writing.

    I enjoy solving people’s problems and make them happy. That is what I have been doing for many years now.
    I have been writing since I was 12 years old and never knew it would turn out to be a full-time career. I have also been able to manage several assignments that involves writing. And I worked in three organizations as a volunteer to assist people.My hobbie has always been to help people succeed. And I go the extra mile to make that happen.
    I enjoy writing Thesis and have helped people from countries like USA.
    I work with a company whose mission is to provide quality works and make people happy. In fact, many clients come to me for professional help on a daily basis because they know I always deliver. And I will continue to provide nothing but the best to build trust like I have been doing for the past few years.

    Expert writer - Liam Scott - natalie3107 Corps

  10. hayley Says:

    Hello, my name is Hayley!

    I`m a professional writer and I`m going to change your lifes on?e and for all
    Writing has been my passion for a long time and now I can`t imagine my life without it.
    Most of my books were sold throughout Canada, USA, Old England and even India. Also I`m working with services that help people to save their time.
    People ask me "Hey, Hayley, I need your professional help" and I always accept the request, `cause I know, that only I can solve all their problems!

    Professional Writer - Hayley - Mary MaddysonConfederation

  11. sebastien Says:

    Welcome to my blog ! I’m Sebastien.
    Even though I jokingly credit my grandmother for my writing talent, I know that it is a ability I have fostered from childhood. Though my aunt is a writer, I also started out young.
    I’ve always had a way with words, according to my favorite educator. I was always so excited in science when we had to do a research paper .
    Now, I help current students achieve the grades that have always come easily to me. It is my way of giving back to communities because I understand the obstacles they must overcome to graduate.

    Sebastien – Professional Writer – url=http://www.spoke.com/companies/7-tips-to-improve-your-business-writing-5df241492c5326c5ab000c36]7 Tips To Improve Your Business Writing Corps

Leave a Reply