tanya@adds.newyork.NCR.COM (Tanya Katz) (09/13/89)
In <1827@sialis.mn.org> (Robert J. Granvin) writes: |Basically, stock UUCP under at least certain conditions with the OBM, |will ignore any lockfile that is over one hour old, making the (incorrect) |assumption that the job is too old, and therefore must not be active |anymore (it was a "safety feature" for the original market of the machine). | |So, if you have a currently running process that's an hour or more old, and |you kick off a poll, the lockfile will be ignored, uucico will start up and |grab the phone line, which will just cause havoc, and your call will die. | |If you have your own daemon or cron script that kicks off polls, it's a wise |measure to make sure that the lockfile is indeed invalid before you just pop |off to uucico. | A while back there were several phone programs posted to the net that check the line status and toggle the mode. These were the inspiration for my own program called newph, that checks if the line is in use by trying to detect a dial-tone. I use the newph program in my uudemon.hr which is run by cron at 05 after the hour, and added the following lines to my uudemon.hr file: /u/bin/newph DATA > /dev/null if [ $? -ne 0 ] then exit 1 fi # after the uucico -r1 : /u/bin/newph VOICE I only have one phone line and want it to be free before attempting to dial out. This program is silent. My family said that when they are using the phone they cannot hear the extension being taken off the hook with this program (and associated clicking when the line gets turned by the regular /usr/bin/phtoggle program). If uucico is running from some prior invocation, the line will already be in data mode, and I decided that I would not like cron to start uucico if the newph program finds the line already set to DATA. This is just a personal choice, but it seems to be fairly trouble free. I also have a uutry script that has the "/u/bin/newph DATA" command in it too. This will kick off the uucico to the desired system, after turning the line; and after the transfer, it will turn the line back. So when the data transfer begins, I can do something else, and the phone line will be reset afterwards. Here is a copy of the newph.c program designed to run with phone mgr v3.51: o / o / o / o / --Cut-------X------Cut------X-------Cut-----X-------Cut-----X----Cut- o \ o \ o \ o \ #include <stdio.h> #include <fcntl.h> #include <sys/phone.h> #define ERROR -1 struct updata phdata; char *arg0; main(argc,argv) int argc; char *argv[]; { int phone, data, error; char phport[30], msg[80]; /* no argument: call /usr/bin/phtoggle... */ if (argc == 1) turn_line(); arg0 = argv[0]; if (strcmp(argv[1],"VOICE") == 0 ) data = 0; else if (strcmp(argv[1],"DATA") == 0) data = 1; else { printf("usage: %s [VOICE|DATA]\n", arg0); exit(1); } /* Open the phone line 0 */ sprintf( phport, "%s0", PHDEV); if ( (phone = open( phport, O_RDWR | O_NDELAY )) == ERROR ) { sprintf(msg, "Couldn't open port '%s'", phport); fatal(phone,msg); } /* Get the phone-line settings */ ioctl(phone,PIOCGETP,&phdata); if ( ( error = ioctl(phone,PIOCOFFHOOK,&phdata)) == ERROR ) sprintf(msg,"Phone in use, try again later."); /* Release the line */ if ( ioctl(phone,PIOCDISC,&phdata) == ERROR ) { sprintf(msg,"Error hanging up line."); error = 1; } close( phone ); if ( error ) fatal(msg); if ( data ) { if (phdata.c_lineparam & DATA) exit (1); } else if (phdata.c_lineparam & VOICE) exit (1); turn_line(); } turn_line() { if ( system( "/usr/bin/phtoggle" ) != 0 ) { perror("phtoggle"); exit (1); } exit(0); } fatal( msg ) char * msg; { printf( "%s: %s\n", arg0, msg); exit(1); } /* Tanya :-------------------------------------------------: | Tanya Katz (516) 231-5400 x430 | | | | ...uunet!ncrlnk!adds!tanya | | tanya.katz@adds.newyork.ncr.com | | | | ADDS Inc, 100 Marcus Blvd, Hauppauge, NY 11788 | :-------------------------------------------------: */