dannyman.toldme.com

About Me : Free Style : Good Reads : News and Reaction : Photographs : Technical : Travels : Unsorted

Search:
July 26, 2006
Technical

Unix Trick: Block-and-Page

Well, I hope to give some cool narrative of the big move to San Francisco, the awesomeness of my new pad, and the joy joy experience of a hip new job, but for now, I’ll share a little Unix trick.

You ever had a job to do that consisted of issuing a time-consuming command, waiting a long time, then issuing the next time-consuming command, waiting a long time . . . meanwhile, you wander off and focus on other things and the time-consuming command has completed but long ago you stopped paying any attention whatever?

Well, what I do, is ask Unix to page me when the command completes. “Hey, boss! Wake up! Time to look at me again!”

This is pretty easy to rig up. For example, this morning I had to copy a series of CD-ROMs, swapping between each copy, so my command looks like:
cp -rp /media/cdrom/* 10.1 && echo "copy done" | mail -s "copy done" pager@example.com

If you don’t already “get” it, I’ll explain:

cp -rp /media/cdrom/* 10.1
This is the time-consuming command: copy the contents of the CD-ROM to a directory.
&&
This means “if the last command completed successfully, execute the next command.” Like a conditional operator in your favorite programming language. Of course, in this context, ;; is probably smarter, as it means “after the last command terminates, successfully or otherwise, execute the next command.” (Even if the copy screws up, I still want to know, right?)
echo "copy done" | mail -s "copy done" pager@example.com
Say “copy done” and send that to the mail command, with the subject “copy done”, and send that to pager@example.com.

Hrmmm, my pager just went off. I guess I am done posting for now!

Read More

Next: Week 1
Previous: Sunday’s Note
Categories: Technical
Possibly-Related Posts
Quick Unix Tip: “Look”
Better Unix Through System Graphs
Shell HOWTO: Remove Duplicate Elements from a Variable
HOWTO: Play random mp3s with mpg123
HOWTO: Archive Audio Streams in to mp3 Files
evidence that I need a life
Perl: Convert Celsius and Fahrenheit

Responses

July 27th, 2006

Nick

Ha ha Danny … you’re still helping me and you don’t work here anymore!

July 27th, 2006

Ji Village News

Great trick! Keep ‘em coming.

It’s in my Google Notebook now :)

August 11th, 2006

Fee

I like that… what other mail command you have. maybe one for a block echo command that need to be redirected to you work e-mail

August 11th, 2006

The Ji Village News » View and kill processes in Linux and Solaris

[...] This is more of note to myself as I am doing more work on Linux and Solaris environment. Hope you find it helpful. Let’s just say I have a long, long way to go before I reach Dannyman’s level. [...]

August 16th, 2006

Russ

Under Mac OS X I sometimes do a variation on this using the ’say’ command line utility that speaks whatever text you give it. For example:
cp -rp /media/cdrom/* 10.1 ; say “copy finished”
Useful for when you’ve got the window in the background or you’re near your computer at least.

Post a Public Comment

The Rules:

  1. For private messages, e-mail me: dannyman@toldme.com
  2. I will not publish or share your e-mail address.
  3. I will not spam you.
  4. Therefor: no anonymous posts; send me your e-mail address!
(required)
(required)

. . . comments from new posters will be held for screening.

Danny Howard is 100% responsible for the content on this site, except some of it is stolen.

All rights are reserved, unless otherwise noted. Generally, I'm a BSD guy, so you can assume implicit permission to adapt, modify, and redistribute my intellectual property with appropriate attribution. Except some of this content is itself re-appropriated, so you'd best ask first, especially for commercial use. Thanks!

You can contact me via e-mail: dannyman@toldme.com

Most of http://dannyman.toldme.com/ is powered by WordPress.

If you're hip to RSS and whatnot, you can subscribe to this site.

These links are for dannyman: login AND backlinks