lab.joelgillman.com

Sketches, Code Bites and Toys




Pseudo Work (fwork)
2009-11-05

This script takes a text file (any text file should) and displays it one line at a time with short delays in between. In other words, you can run this script to make it look like your computer is actually doing something worthwhile.

I had searched around the internet a few times but never really found anything like this, but that doesn’t mean it doesn’t look. Maybe I’m just a bad internet searcher. Script after the jump.


#!/bin/bash

#####################################################
# Pseudo Work (fwork) Script - by Joel Gillman 2009
# lab.joelgillman.com/archives/159_pseudo-work
#
# Please feel free to edit and change this as you
#  like! If  you do make any edits I would be curious
#  to see what you've done so drop me a line!
#
# DISCLAIMER
# I am in no way a bash scripting expert. Most of what
#  I write is copy and paste and trial and error.
#  While this script shouldn't hurt anything in your
#  system don't hold me responsible if it does! Use
#  at your own risk.
#####################################################


## test if file (default or otherwise)
if [ "$1" = '' ]; then
    filename="$HOME/garbage.txt"
    if [ -e $filename ]; then
        sleep 0
    else
        echo "No file specified and default file '~/garbage.txt' not found."
        exit
    fi
elif [ -e $1 ]; then
    filename=$1
else
    echo "No file found at $1"
    exit
fi

## execute fakeness
while read p; do
    if [ "$(($RANDOM % 10))" -eq 1 ]; then
        let "R1 = ($RANDOM % 2)"
    elif [ "$(($RANDOM % 50))" -eq 1 ]; then
        let "R1 = ($RANDOM % 20)"
    else
        let "R1 = 0"
    fi
   
    let "R2 = ($RANDOM % 10)"
    echo $p
    sleep $R1.$R2
done < $filename

Download a zip’d version of the script.
You can download the (2.5MB) text file I’ve been using.

Let me know what you think! Any improvements or suggestions would be greatly appreciated.



Share
Tags: , , , , ,

trackback URL for this post: http://lab.joelgillman.com/archives/159_pseudo-work/trackback

comments as feed

Post a Comment

Your email is never published nor shared.
Required fields are marked *
*
*



© 2010 jgillman -¦- Go WordPress! -¦- RSS 2.0 Feed