Skip to content

Instantly share code, notes, and snippets.

@ralphbean
Created May 29, 2012 15:29
Show Gist options
  • Select an option

  • Save ralphbean/2829079 to your computer and use it in GitHub Desktop.

Select an option

Save ralphbean/2829079 to your computer and use it in GitHub Desktop.
Script to upload little stdout blurbs.
#!/bin/bash
# Script to take the output of commands and post them to a tmp web directory
# for easy sharing. Requires python-ansi2html.
#
# Author: Ralph Bean <[email protected]>
# License: GPLv3+
# Edit the following three variables to suit your needs
WEB_USER=your_username
WEB_HOST=your_site.org
WEB_DIR=~/public_html
# ~/public_html/tmp needs to already exist on $WEB_HOST
echo "Creating file"
outfile=$(mktemp --suffix=.html)
ansi2html < /dev/stdin > $outfile
chmod o+r $outfile
echo "Uploading $outfile"
scp $outfile $WEB_USER@$WEB_HOST:$WEB_DIR$outfile
echo "Removing $outfile"
rm $outfile
echo
echo http://$WEB_HOST$outfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment