Path: utzoo!attcan!uunet!lll-winken!netsys!ssbn!bill From: bill@ssbn.WLK.COM (Bill Kennedy) Newsgroups: comp.unix.microport Subject: Re: Dropping DTR? Summary: Kill the getty inittab and process Message-ID: <916@ssbn.WLK.COM> Date: 22 Jan 89 18:34:25 GMT References: <362@cocktrice.UUCP> Reply-To: bill@ssbn.WLK.COM (Bill Kennedy) Organization: W.L. Kennedy Jr. and Associates, Pipe Creek, TX Lines: 101 I started to mail this but I thought that it might be useful since some might be sharing a voice line with a modem. In article <362@cocktrice.UUCP> mdm@cocktrice.UUCP (Mike Mitchell) writes: >Does anyone have a fancy trick for lowering DTR going to a modem attached >to tty0? I have my modem set up to auto answer, however there are times >that I do not want the modem to answer the phone. The obvious things would be to unplug either the phone line or serial cable from the modem, but those leave you vulnerable to forgetting to plug them back in. You could also arm and disarm with echo "ATQ1S0=0" > /dev/ttyM0 to disarm it and the reverse to rearm it. If you're going to do it this way, make sure that you use the Q1 so that the modem doesn't torture the getty with result codes that the phone is ringing. >I can start a getty running on /dev/ttyM0 and the DTR comes up. When I kill >the getty, the DTR drops for a moment and then comes up again. The modem >still answers the phone, but there is nothing running to accept logins. That's odd. The first part is quite understandable because init spawns a new getty when the old one dies, but it should prompt for a login, i.e. it should be a shiny new getty ready to go. >If I do not run a getty, the DTR behaves "properly" when making outgoing >calls. UUCP will dial out and connect and when it is finished the DTR is >dropped when /dev/tty0 is closed. You need to alter the inittab to not respawn the getty and then you need to kill the getty itself, see below. >-- >Mike Mitchell BELL: (505) 471-7639 >2020 Calle Lorca #43 ARPA: mdm@cocktrice.UUCP >Santa Fe, NM 87505 UUCP: ...!uunet!dmk3b1!cocktrice!mdm I have the same problem from time to time when I need the voice line to do double duty, particularly at night. It's also rather handy to have the modem to answer late night calls when I don't want to be disturbed. I run a job with cron that arms and disarms a modem on the voice line. Using the following inittab line as an example - T0:23:respawn:/etc/getty ttyM0 2400 # # disarm ttyM0, runs from cron at 0630 each morning # # Start by changing the /etc/inittab line from respawn to off # TMP=/tmp/tty$$ chmod u+w /etc/inittab ed - /etc/inittab <<'EOF' /T0/s;respawn;off; w q EOF chmod u-w /etc/inittab # # Now find and kill the getty, this is modified from # what I use to kill all uugetty's that are active. # ps -e | grep getty > $TMP if [ -s $TMP ] then cat $TMP | while read pid tty time command do if [ "ttyM0" = "$tty" -a "getty" = "$command" ] then set - $pid; pid=$1; kill -9 $pid fi done fi rm -f $TMP chmod /etc/inittab u-w Now something similar to arm the port. # # arm ttyM0, run from cron at 2330 # # All we have to do is change off to respawn and # tell init to look at inittab again. # chmod u+w /etc/inittab ed - /etc/inittab <<'EOF' /T0/s;off;respawn; w q EOF chmod u-w /etc/inittab /etc/telinit q Since it requires root permissions to modify /etc/inittab I will leave the cron line up to the reader. I'm ASSuming that Mike's system is like mine, a small one where the owner can pretty much do as they please. There are probably some undesirable side effects to such brute force in a different environment but the technique has worked well on my systems. -- Bill Kennedy usenet {killer,att,cs.utexas.edu,sun!daver}!ssbn!bill internet bill@ssbn.WLK.COM