diff -u -r mailblink-0.7/led.c mailblink-0.7.new/led.c
--- mailblink-0.7/led.c	Mon Nov  5 09:14:54 2001
+++ mailblink-0.7.new/led.c	Sat Apr 13 19:53:02 2002
@@ -27,8 +27,8 @@
 #include <pthread.h>
 #include <assert.h>
 
-/* Parport stuff */
-#include <sys/io.h>
+#include <sys/io.h> /* Parport stuff */
+
 /* Hmmm... FIXME, hardcoded... but I don't care as long as it works ;) */
 #define DATA 0x378
 #define STATUS (DATA+1)
@@ -39,10 +39,13 @@
 #define SCROLLLOCKLED   3
 #define KEYBOARDDEVICE	"/dev/console"
 
-typedef enum { CLEAR = 0, SET = 1, TOGGLE = 2 } LedMode;
+#define CLEAR 0
+#define SET 1
+#define TOGGLE 2
 
+/* also used from mailblink.c */
+void led( int what, int mode /* CLEAR, SET, TOGGLE */ );
 /* Declarations of functions local to this file */
-void led( int what, LedMode mode );
 void toggle_led( int what );
 void clear_led( int what ) { led( what+1, CLEAR ); }
 void set_led( int what ) { led( what+1, SET ); }
@@ -55,20 +58,40 @@
 int blinks = 0;
 /* Flag tells us when the led is toggled */
 int tflag = 0;
+/* >0: Do not blink, just set the led state and exit */
+int setandexit;
 
 extern int verbosity;
 extern void message( int level, const char *format, ... );
 
-void my_led_exit( void *not_used ) {
-    message( 2, "my_led_exit() called\n" );
-
-    if( tflag ) toggle_led(lednum);
+void prepareled() {
+    if( -1 == (keyboardDevice = open(KEYBOARDDEVICE, O_RDONLY))) {
+        assert(0);
+    }
+  
+    if (lednum >= 3) {
+        if (ioperm(DATA,3,1)) {
+	    printf("Sorry, you were not able to gain access to the ports\n");
+	    printf("You must be root to run this program with parallel port support\n");
+	    exit(1);
+	}      
+    }
+}
 
+void releaseled() {
     if( keyboardDevice ) {	/* EUID root - CONSOLE */
 	(void) close( keyboardDevice );
     }
 }
 
+void my_led_exit( void *not_used ) {
+    message( 2, "my_led_exit() called\n" );
+
+    if( tflag ) toggle_led(lednum);
+    
+    releaseled();
+}
+
 void *led_thread( void *not_used ) {
 /* loops forever, blinking the led according to 
  * the blinks variable */
@@ -78,21 +101,11 @@
 
     pthread_cleanup_push( my_led_exit, NULL );
 
-    if( -1 == (keyboardDevice = open(KEYBOARDDEVICE, O_RDONLY))) {
-	assert(0);
-    }
-
-    if (lednum >= 3) {
-      if (ioperm(DATA,3,1)) {
-	printf("Sorry, you were not able to gain access to the ports\n");
-	printf("You must be root to run this program with parallel port support\n");
-	exit(1);
-      }      
-    }
+    prepareled();
 
     while(1) {
         if ( blinks == -1 ) {
-  	    /* fast flickering indicates an error */
+	    /* fast flickering indicates an error */
 	    toggle_led(lednum);
 	    usleep(80000);
 	    toggle_led(lednum);
@@ -113,7 +126,7 @@
     pthread_cleanup_pop( 1 );
 }
 
-void led( int led, LedMode mode ) {
+void led( int led, int mode ) {
 /* This is the actual function that sets/clears/toggles an led */
     char ledVal;
 
diff -u -r mailblink-0.7/mailblink.1 mailblink-0.7.new/mailblink.1
--- mailblink-0.7/mailblink.1	Tue Nov  6 10:32:36 2001
+++ mailblink-0.7.new/mailblink.1	Sat Apr 13 20:07:45 2002
@@ -13,6 +13,12 @@
 ] 
 .RB [ \-l <led>
 ] 
+.RB [ \-0
+] 
+.RB [ \-1
+] 
+.RB [ \-2
+] 
 .RB [ \-q
 ]
 .RB [ \-v
@@ -70,6 +76,17 @@
 .b parport7.
 If not specified scroll lock is chosen by default.
 .TP
+-0
+Clear the specified led and exit. No mailbox is checked. This is
+useful to build own external scripts and to check if the led
+is still working.
+.TP
+-1
+Light the specified led. Same as above.
+.TP
+-2
+Toggle the specified led. Same as above.
+.TP
 -q
 Quiet.  Use -qq for very quiet.
 .TP
@@ -110,11 +127,17 @@
 every 10 minutes and blinks the LED attached to the
 .B parport DATA0
 pin. Don't forget to protect your file (eg chmod 0600 
-/etc/mailblink1) since it contains passwords.
+/etc/mailblink1) since it contains the password.
 .TP
 .B mailblink -k -l num
 Attempts to kill the mailblink process controlling the num
 lock light.
+.TP
+.B mailblink -l parport3 -1
+Light the led on parport3 and exit, without forking into 
+background. You could put something like this in your crontab:
+.br
+.B 0 * * * * root   ping -c 1 www.test.org && mailblink -l parport5 -1 || mailblink -l parport5 -0
 .TP
 .B mailblink -q
 Attempts to start mailblink quietly.  Won't print status
diff -u -r mailblink-0.7/mailblink.c mailblink-0.7.new/mailblink.c
--- mailblink-0.7/mailblink.c	Tue Nov  6 10:49:51 2001
+++ mailblink-0.7.new/mailblink.c	Sat Apr 13 19:54:32 2002
@@ -1,5 +1,5 @@
 /* Copyright (C) 1999 Donald J Bindner
- * Copyright (C) 2001 Martin Renold
+ * Copyright (C) 2002 Martin Renold
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -51,7 +51,11 @@
 /* These control blinking in another thread */
 extern int lednum;
 extern int blinks;
+int setandexit;
 extern void *led_thread( void *not_used );
+extern void prepareled();
+extern void releaseled();
+extern void led( int what, int mode );
 /* proto for the check loop */
 void check_loop( void );
 
@@ -90,6 +94,9 @@
 \t         \t  >>imapserver username passwd [port] [mailbox]\n\
 \t-k\t\tKill old processes.\n\
 \t-l <led>\tLed to blink (num, caps or scroll, parport0 - parport7)\n\
+\t-0\t\tClear the led and exit (no mail check)\n\
+\t-1\t\tLight the led and exit (no mail check)\n\
+\t-2\t\tToggle the led and exit (no mail check)\n\
 \t-q\t\tDecrease verbosity.  Repeat for even less.\n\
 \t-v\t\tIncrease verbosity.  Repeat for even more.\n\
 \t-D\t\tDebug.  Don't fork into the background.\n", MYNAME, VERSION, MYNAME );
@@ -249,11 +256,13 @@
     if( sigaddset( &sigset, SIGTTOU )) assert(0);
     if( sigprocmask( SIG_BLOCK, &sigset, NULL )) assert(0);
 
+    setandexit = 0;
+
     /* We'll start with the file from $MAIL but let the user overide */
     filename = getenv( "MAIL" );
 
     /* Get all of the command line switches */
-    while( EOF != ( c = getopt( argc, argv, "Dd:f:hkl:p:qv" ))) {
+    while( EOF != ( c = getopt( argc, argv, "Dd:f:hk012l:p:qv" ))) {
 	switch( c ) {
 	    case 'D':
 		opt_D = 1;
@@ -280,6 +289,15 @@
 		}
 		if( lednum == -1 ) help_exit();
 		break;
+	    case '0':
+                setandexit = 1;
+		break;
+	    case '1':
+                setandexit = 2;
+		break;
+	    case '2':
+                setandexit = 3;
+		break;
 	    case 'q':
 		verbosity--;	/* lower verbosity */
 		break;
@@ -295,6 +313,13 @@
     if( geteuid()) {
 	message( WARN, "This program requires root privelege to run.\n" );
 	exit( 1 );
+    }
+
+    if (setandexit) {
+       prepareled();
+       led(lednum+1, setandexit-1);
+       releaseled();
+       exit( 0 );
     }
 
     /* use POP3/IMAP */
