I'm William L. Dye ("willdye"), a programmer from Lincoln, Nebraska, USA. I'm not a Bash expert, but I've contributed to this wiki in the past, and might contribute again sometime, so I might as well create an account here.

I typically program in C/C++, Tcl/Tk, and Bash; and occasionally program in Python, Awk, and Lisp. I can't even remember all the languages I've used over the years, but it's a long list (Fortran, APL, various assembers, et alibi). I can also use Java. If I have to. I guess.

I currently program on the Windows and Linux platforms, mostly in the XP and Red Hat varieties. In the past, I've used IBM mainframes (mostly 370 MVS), BSD, HP/UX, and Macintosh. In acient days of long ago, I've used CP/M, DOS, Amiga, CDC mainframes, TRS-80, Commodore 64, Altair 8800, custom machine controllers (8080 and Z-80), and a bunch of other crufty old things that I can barely even remember now.

Yeah, I'm that old. And just so you know, we really did walk 20 miles to school and back, and it was uphill both ways! And we didn't have your fancy ones and zeros back then. Why, I had to write an entire database with just zeros! Wimps! Learn to program using a soldering iron, ya slackers! Mutter, mutter, mumble...

This is some code that I might post in the Bash FAQ or open questions pages, if I can determine that it's a good solution (or fix the problems, if I can find any). Do NOT trust this code -- it's just a draft.

Suppose you have multiple computers, only one of which operates your desktop environment, and you want the other machines to notify the desktop machine if something noteworthy happens. The definition of "noteworthy" doesn't matter to this example code, but it could be a disk which is getting dangerously full, or incoming mail that matches a certain pattern. Anyway, here's some very simple Bash and Tcl code which allows the desktop machine to easily listen for events from the other machines.

First, a quick test to see if it can work on your system. On the desktop machine, run this at a Bash prompt, or put the equivalent into a Tcl program:

tclsh<<<'proc respond {channel address port} {puts "$channel $address $port [gets $c]"; close $c}; socket -server respond 8765; vwait forever'

On the other machine(s), run this Bash program:

while sleep 3; do date > /dev/tcp/desktop.yourdomain.com/8765; done

...where "desktop.yourdomain.com" is the name or I.P. address of your desktop machine.

If that fails, then don't bother making the programs any fancier until you figure out what's wrong. If your firewall is blocking the port, or the port is in use by another program, try some other port.

If it works, then every three seconds or so, you should see the current date appear on the server side. Now you can extend the programs to run some particular program if some particular condition is satisfied. Another use is for the server (desktop) side to raise an alert if a particular client hasn't sent a message in a long time, indicating that the client has been disconnected.