vern@zebra.UUCP (Vernon C. Hoxie) (01/16/89)
I was looking through the code for 'pcomm2' and saw that they had a system('setgetty tty mode') call. Looking through my manuals, I cannot find any reference to this command. Upon listing the /usr/bin, I find that such a command is indeed part of the set. It has but one link, so I infer that it is not an optional entry to some other command. Where can I get documentation on this command and how many other goodies are present in the system which are not documented? BTW when I was reading about linking 'zcat' to 'compress' to get an optional usage, I remembered reading in "UNIX System Administration" by David Fiedler and Bruce H. Hunter, Hayden Books, about optional commands to 'ls'. They said that linking 'll' to 'ls' would produce a long listing without having to add options. I tried it and I like it. The book lists other links to 'ls' to simulate the '-m', '-r', '-F' and '-x' options. The links are 'l', 'lr', 'lf' and 'lx'. They are listed on page 22 if you have that book. -- Vernon C. Hoxie {ncar,nbires,boulder,isis}!scicom!zebra!vern 3975 W. 29th Ave. voice: 303-477-1780 Denver, Colo., 80212 uucp: 303-455-2670
jbm@uncle.UUCP (John B. Milton) (01/20/89)
In article <143@zebra.UUCP> vern@zebra.UUCP (Vernon C. Hoxie) writes: > > I was looking through the code for 'pcomm2' and saw that they >had a system('setgetty tty mode') call. Looking through my manuals, I >cannot find any reference to this command. Upon listing the /usr/bin, I >find that such a command is indeed part of the set. It has but one link, >so I infer that it is not an optional entry to some other command. This is a very simple program that toggles the space/colon at the beginning of the /etc/inittab file. Unfortunately, it sometimes gets stuck in a loop looking at the /etc/utmp file and block your port until you kill it. Below is my simpler version that doesn't lock up > Where can I get documentation on this command and how many other >goodies are present in the system which are not documented? If you can't find it in the User's Manual Vol I, you're SOL > BTW when I was reading about linking 'zcat' to 'compress' to get >an optional usage, I remembered reading in "UNIX System Administration" >by David Fiedler and Bruce H. Hunter, Hayden Books, about optional >commands to 'ls'. They said that linking 'll' to 'ls' would produce a >long listing without having to add options. I tried it and I like it. >The book lists other links to 'ls' to simulate the '-m', '-r', '-F' and '-x' >options. The links are 'l', 'lr', 'lf' and 'lx'. They are listed on >page 22 if you have that book. You should get the full compress distribution, as it comes with some other programs: atob, btoa, compressdir, tarmail, uncompressdir, untarmail, zcmp, zdiff, zmore. These are programs, not just links. Here's the rest of the story: ls looks at the last two characters of argv[0]: *[!l]l == ls -m *ll == ls -l *lr == ls -R *lf == ls -F *lx == ls -x * == ls There is also a -n switch, which is not documented. It turns on long (-l) mode and displays the uid/gid as a number instead of text (doesn't open /etc/passwd) This is also a -A switch, which is on by default if ls is run by root. This switch shows all .[!.]* files, but not . and .. I have seen the -n and -A switches properly documented on other UNIX systems. John (the whole story) Milton -- John Bly Milton IV, jbm@uncle.UUCP, n8emr!uncle!jbm@osu-cis.cis.ohio-state.edu (614) h:294-4823, w:764-2933; Got any good 74LS503 circuits? --- #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: setgetty.c # Wrapped by jbm@uncle on Fri Jan 20 04:01:34 1989 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'setgetty.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'setgetty.c'\" else echo shar: Extracting \"'setgetty.c'\" \(3071 characters\) sed "s/^X//" >'setgetty.c' <<'END_OF_FILE' X/* vi:set ts=2 sw=2: XThis is a replacement for the UNIXpc program "setgetty". This program is run Xby the files /usr/bin/geto{n|ff}.sh, which are run by the dial(3) library call Xto get the getty off a tty line when dialing out, and to put it back when done. XThat's all well and good, except it screws up sometimes and just sits there Xwith the getty offm chewing up CPU and NOT turning the getty back on. I'm not Xentirely sure why it gets stuck. I think it has something to do with the fact Xthat it's looking at the /etc/utmp file to decide if there is currectly a user Xor login process on the line. This program does not check the utmp file. This Xis what it DOES do: X X1. Open /etc/inittab r/w X2. Read the whole thing into a buffer in one call X3. Finds the first occurance of the right label X3. Sets the first character to a space or colon X4. If a change was done, it writes the inittab back out in one call. X XYou may ask "What, documentation, what is this?". Well, this program, like Xsetgetty has to have the executable owned by and setuid root: X-rwsr-xr-x 1 root bin 2156 Jan 1 1970 /usr/bin/setgetty X XInstalltion: X1. cc -cO -o sg.o sg.c X2. ld -s -o sg /lib/crt0s.o /lib/shlib.ifile sg.o X3. chown root sg X4. chmod 4755 sg X5. mv /usr/bin/setgetty /usr/bin/osetgetty X6. mv sg /usr/bin/setgetty X XFor some reason, cu and uucico through dial(3) don't run getoff.sh when the Xprogram running on the line is not a LOGIN process. Hmm, beats me. As always, Xlet me know if you have any problems: John B. Milton, jbm@uncle X*/ X X#include <fcntl.h> X#include <stdio.h> X#include <string.h> X X#define BUFSIZE 4096 X Xextern int errno; X Xvoid qperrorf(format,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) Xchar *format,*a1,*a2,*a3,*a4,*a5,*a6,*a7,*a8,*a9; X{ X char line[200]; X int curerrno=errno; X sprintf(line,format,a1,a2,a3,a4,a5,a6,a7,a8,a9); X errno=curerrno; X perror(line); X exit(curerrno); X} X Xstatic char *usage="Usage: %s xxx 0|1\n"; Xstatic char *it="/etc/inittab"; X Xint main(argc,argv) Xint argc; Xchar *argv[]; X{ X int f,len; X char look,new,*s,buf[BUFSIZE]; X X if (argc!=3 || strlen(argv[1])!=3 || (argv[2][0]!='0' && argv[2][0]!='1')) { X fprintf(stderr,usage,argv[0]); X exit(0); X } X if ((f=open(it,O_RDWR))==-1) X qperrorf("%s: open r/w %s",argv[0],it); X if ((len=read(f,buf,BUFSIZE))==-1) X qperrorf("%s: read %s",argv[0],it); X if (len==BUFSIZE) { X fprintf(stderr,"%s: error, BUFSIZE too small\n",argv[0]); X exit(3); /* new status, setgetty didn't have this one */ X } X if (argv[2][0]-'0') { look=':'; new=' '; } else { look=' '; new=':'; } X for (s=buf; s<buf+BUFSIZE-20; s++) X if (*s=='\n' && (*(s+1)==' ' || *(s+1)==':') && strncmp(s+2,argv[1],3)==0) { X if (*(s+1)!=new) { X *(s+1)=new; X lseek(f,0,0); X if ((len=write(f,buf,len))==-1) X qperrorf("%s: re-write %s",argv[0],it); X if (close(f)==-1) X qperrorf("%s: close %s",argv[0],it); X kill(1,1); /* very quick telinit Q */ X } X if (new==' ') X exit(0); /* dial(3) doesn't care about turning the getty on */ X else X exit(2); /* this is success, believe it or not */ X } X exit(1); /* line not found */ X} END_OF_FILE if test 3071 -ne `wc -c <'setgetty.c'`; then echo shar: \"'setgetty.c'\" unpacked with wrong size! fi # end of 'setgetty.c' fi echo shar: End of shell archive. exit 0