Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

statico (5018)

statico
  ian.langworthNO@SPAMgmail.com
http://langworth.com/
AOL IM: eisforian (Add Buddy, Send Message)

PAUSE-ID: IAN [cpan.org]

Co-author of Perl Testing: A Developer's Notebook [oreilly.com]

Journal of statico (5018)

Saturday August 20, 2005
09:20 AM

new journalizer, stare and better than homebrew

[ #26395 ]

Taking pudge's suggestion, I modified my use Perl; Journalizer application to use the SOAP API instead of the slightly-buggy WWW::UsePerl::Journal. Now I can write journal entries in spell-checked, minimal-syntax KwikiText and not worry that comments are disabled.

Speaking of tools, have you ever searched for a small utility, only to find in disbelief that no one has already written it, then written it yourself? The most memorable tool in my case is a utility I call "stare."

I'm sure we've needed to watch repeatedly the output of some command. Maybe it was the listing of a directory or some program that reports status information. In those cases, this might come to mind:

$ while true; do clear; some-command; sleep 1; done

The problem with the above is that the display flickers. "Okay," you might say, "so why not recreate it with Curses?" Well, fair reader, that's exactly what I did almost two-and-a-half years ago. I called it "stare" and used it as an excuse to learn the Curses module. I included two useful options: the ability to hide the header line and the number of seconds to refresh. With the exception of resizing the terminal, it mostly works.

I was recently in an environment where installing Perl modules was, at the time, not an option. Remembering that David uses something called "vis," I searched and found vis.c, an example from Unix Power Tools, 3rd ed.. I did have access to gcc so I began to use it, even though it has the terminal-resizing bug and a small hatred for certain argument combinations.

Now here's the kicker: I needed to abstract vis into another utility, which I called watchconf. A few minutes later, when I went to use my shiny new command, tab-completion caused me to blink:

$ watch
watch      watchconf

Eh? What is this watch you speak of?

$ man watch
NAME
     watch - execute a program peri-
     odically,    showing     output
     fullscreen

No way!

SYNOPSIS
     watch  [-dhvt]  [-n  <seconds>]
     [--differences[=cumulative]]
     [--help] [--interval=<seconds>]
     [--no-title] [--version]  <com-
     mand>

NO!

DESCRIPTION
     watch  runs command repeatedly,
     displaying  its   output   (the
     first screenfull).  This allows
     you to watch the program output
     change  over time.

Yes, folks, this utility comes with the "procps" package, which is installed on Debian Sarge / Ubuntu Hoary by default, AFAIK. Not only has it been there all along, but it includes a "highlight differences" option and it can handle terminal resizing.

I'll sit here patiently and wait for the "told-you-so's."

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Heh, yep. As soon as I saw while true ; clear I thought “doesn’t he know about watch?”

    Amusing way to stumble over it by yourself, though. :-)

  • I go through those myself, but I'm too lazy to write the code, so I usually just shelve the thought or work around it.

    My last one is a 'blank' command, which will blank out a file, but leave it there (0 bytes) with the same privs, owners, etc. But there's prolly a easy workaround, like "echo '' > /path/to/file"

    - Jason
  • I told you about this back when you wrote stare.