Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

uushow - display pending UUCP jobs

1 view
Skip to first unread message

Jan-Piet Mens

unread,
Aug 9, 1991, 4:35:15 AM8/9/91
to
From the README
---------------
This is uushow 1.00

I have always disliked the output of `uustat -a'. I herewith try to improve
on that output, by creating one line per pending job. If you like it, keep it.
Otherwise, /dev/null is a good place for all of this ;-)

#! /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 archive 1 (of 1)."
# Contents: Copyright MANIFEST Makefile README patchlevel.h uushow.1
# uushow.c uushow.h
# Wrapped by jpm@logixwi on Fri Aug 9 10:34:15 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Copyright' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Copyright'\"
else
echo shar: Extracting \"'Copyright'\" \(361 characters\)
sed "s/^X//" >'Copyright' <<'END_OF_FILE'
X/*
X * Copyright 1991, Jan-Piet Mens
X * License to freely use and distribute this software is hereby granted
X * by the author, subject to the condition that this copyright notice
X * remains intact. The author retains the exclusive right to publish
X * derivative works based on this work, including, but not limited
X * to, revised versions of this work
X */
END_OF_FILE
if test 361 -ne `wc -c <'Copyright'`; then
echo shar: \"'Copyright'\" unpacked with wrong size!
fi
# end of 'Copyright'
fi
if test -f 'MANIFEST' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(452 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X File Name Archive # Description
X-----------------------------------------------------------
X Copyright 1 Bla Bla
X MANIFEST 1 This shipping list
X Makefile 1 How to make ...
X README 1 Read me First
X patchlevel.h 1 Release/Version
X uushow.1 1 The manual page
X uushow.c 1 The program
X uushow.h 1 Support macros
END_OF_FILE
if test 452 -ne `wc -c <'MANIFEST'`; then
echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(340 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
XBINDIR=/u/local/bin
XCFLAGS=-s -O
X
X
XOBJ=uushow.o
XSFILES=uushow.c
XHFILES=uushow.h patchlevel.h
X
Xuushow: $(OBJ)
X $(CC) $(CFLAGS) -o uushow $(OBJ)
X
Xinstall: uushow
X cpset uushow $(BINDIR) 4111 uucp uucp
X
X$(OBJ): $(HFILES)
X
Xclean:
X rm -f *.o a.out core
Xclobber: clean
X rm -f uushow
X
Xdist: $(SFILES) $(HFILES)
X makekit -oMANIFEST -h2 < Manifest
END_OF_FILE
if test 340 -ne `wc -c <'Makefile'`; then
echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'README' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(1250 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
XThis is uushow 1.00
X
XI have always disliked the output of `uustat -a'. I herewith try to improve
Xon that output, by creating one line per pending job. If you like it, keep it.
XOtherwise, /dev/null is a good place for all of this ;-)
X
X "uushow will list the uucp jobs that are pending to leave
X this host. The jobs are listed with direction, user who
X requested the job, size of the job, and job content. If the
X displayed size is -1, then the size of the file to be
X received from a remote system is unknown."
X
XInstallation
X============
X
XEdit the Makefile, and set BINDIR to the directory which will contain the
Xfinal executable.
XIf you don't have `cpset', do the following as superuser (root):
X
X # cp uushow BINDIR
X # chmod 4111 BINDIR/uushow
X # chown uucp BINDIR/uushow
X # chgrp uucp BINDIR/uushow
X
XThe program must run as SUID to uucp. This should not be dangerous though,
Xbecause files are only read, and not written.
X
XThis program was developed on SCO UNIX 3.2.2 in a System V environment, and
X*should* work on other environments as well. You may have to tweak the
Xdirectory reading routines a litte ;-)
X
XI wrote this between 8:00 and 10:30. If you find any bugs (I'm sure they are
Xaround) please tell me.
X
XJan-Piet Mens
Xj...@logixwi.uucp
END_OF_FILE
if test 1250 -ne `wc -c <'README'`; then
echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'patchlevel.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'patchlevel.h'\"
else
echo shar: Extracting \"'patchlevel.h'\" \(402 characters\)
sed "s/^X//" >'patchlevel.h' <<'END_OF_FILE'
X/*
X * Copyright 1991, Jan-Piet Mens
X * License to freely use and distribute this software is hereby granted
X * by the author, subject to the condition that this copyright notice
X * remains intact. The author retains the exclusive right to publish
X * derivative works based on this work, including, but not limited
X * to, revised versions of this work
X */
X
X#define RELEASE 1
X#define VERSION 0
END_OF_FILE
if test 402 -ne `wc -c <'patchlevel.h'`; then
echo shar: \"'patchlevel.h'\" unpacked with wrong size!
fi
# end of 'patchlevel.h'
fi
if test -f 'uushow.1' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'uushow.1'\"
else
echo shar: Extracting \"'uushow.1'\" \(1043 characters\)
sed "s/^X//" >'uushow.1' <<'END_OF_FILE'
X.TH UUSHOW 1L "" "Local User Commands"
X.SH NAME
Xuushow - display uucp jobs
X.SH SYNOPSIS
X.B uushow
X[
X.B -V
X]
X[
X.B -v
X]
X[
X.B -a
X]
X[
X.B -s
X.I sysname
X]
X.SH DESCRIPTION
X.B uushow
Xwill list the
X.I uucp
Xjobs that are pending to leave this host. The jobs are listed with
Xdirection, user who requested the job, size of the job, and job content.
XIf the displayed size is
X.I -1,
Xthen the size of the file to be received from a remote system is unknown.
X.PP
X.B uushow
Xrecognizes the following options:
X.PP
X.IP "\fB-a\fR" 0.5i
XShow queued jobs for all systems (default).
X.IP "\fB-s\fR \fIsysname\fR" 0.5i
XShow pending jobs for system
X.I sysname
Xonly.
X.IP "\fB-v\fR" 0.5i
XBe a little bit verbose. This is only for testing purposes.
X.IP "\fB-V\fR" 0.5i
XDisplay version of
X.B uushow.
X.SH NOTES
XOnly one
X.B -s
Xoption may be specified per invocation of
X.B uushow.
X.SH FILES
X.IP "\fI/usr/spool/uucp/*/*" 2i
XThe uucp spool directories and control files.
X.SH BUGS
XTell me please ;-)
X.SH SEE ALSO
Xuucp(1), uustat(1)
X.SH AUTHOR
XJan-Piet Mens - j...@logixwi.uucp
END_OF_FILE
if test 1043 -ne `wc -c <'uushow.1'`; then
echo shar: \"'uushow.1'\" unpacked with wrong size!
fi
# end of 'uushow.1'
fi
if test -f 'uushow.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'uushow.c'\"
else
echo shar: Extracting \"'uushow.c'\" \(6122 characters\)
sed "s/^X//" >'uushow.c' <<'END_OF_FILE'
X/*
X * Copyright 1991, Jan-Piet Mens
X * License to freely use and distribute this software is hereby granted
X * by the author, subject to the condition that this copyright notice
X * remains intact. The author retains the exclusive right to publish
X * derivative works based on this work, including, but not limited
X * to, revised versions of this work
X */
X
X/*
X * $Header: /u/tools/etc/uu/uushow/RCS/uushow.c,v 1.1 1991/08/09 07:01:50 jpm Exp jpm $
X *
X * $Log: uushow.c,v $
X * Revision 1.1 1991/08/09 07:01:50 jpm
X * Initial revision
X *
X */
X
X#include "uushow.h"
X#include "patchlevel.h"
X
X#define USAGE() fprintf(stderr,"Usage: %s [-Vv] [sysname]\n", progname)
X
X#ifndef lint
Xstatic char rcs_id[] = "$Id: uushow.c,v 1.1 1991/08/09 07:01:50 jpm Exp jpm $";
X#endif
X
Xchar *sysname;
Xchar verbose = FALSE;
Xchar *progname;
X
Xmain(argc,argv)
Xint argc;
Xchar **argv;
X{
X char *strrchr();
X extern char *optarg;
X int c;
X
X progname = basename(*argv);
X
X while ((c = getopt(argc,argv,"vVs:a")) != EOF)
X {
X switch (c)
X {
X case 'V':
X printf("uushow version %d.%02d\n",
X RELEASE, VERSION);
X return (0);
X
X case 'v':
X verbose = TRUE;
X break;
X case 's':
X sysname = optarg;
X break;
X case 'a':
X sysname = (char *)0;
X break;
X default:
X USAGE();
X return (1);
X }
X }
X
X return (parse(sysname));
X}
X
X/*
X * Parse the SPOOL directory (/usr/spool/uucp). If `sysname' is NULL, read
X * all directories, else just the dir for `sysname'
X */
X
Xint parse(sysname)
Xchar *sysname; /* NULL if all systems */
X{
X DIR *dirP;
X struct dirent *dp;
X struct stat sb;
X char fullname[BUFSIZ];
X
X if ((dirP = opendir(SPOOL)) == (DIR *)0)
X {
X perror(SPOOL);
X return (1);
X }
X
X while ((dp = readdir(dirP)) != (struct dirent *)0)
X {
X if (dp->d_name[0] == '.')
X continue;
X /*
X * Is this the directory we have specified with '-s' ?
X */
X
X if ((sysname != (char *)0) && strcmp(sysname,dp->d_name))
X continue;
X
X sprintf(fullname,"%s/%s",SPOOL, dp->d_name);
X if (stat(fullname, &sb) == -1)
X {
X fprintf(stderr,"Can't stat(%s): ", fullname);
X perror("");
X continue;
X }
X if ((((sb.st_mode & S_IFMT) & S_IFDIR) == S_IFDIR) &&
X (access(fullname, 05) == 0) )
X {
X checkup(fullname);
X continue;
X }
X }
X (void) closedir(dirP);
X return (0);
X}
X
X/*
X * Parse the spool directory for one system (/usr/spool/uucp/fubar) and
X * find all C. files.
X */
X
Xint checkup(name)
Xchar *name;
X{
X DIR *dirP;
X struct dirent *dp;
X struct stat sb;
X char fullname[BUFSIZ];
X
X if ((dirP = opendir(name)) == (DIR *)0)
X {
X perror(name);
X return (1);
X }
X
X
X while ((dp = readdir(dirP)) != (struct dirent *)0)
X {
X if (dp->d_name[0] == '.')
X continue;
X sprintf(fullname,"%s/%s",name, dp->d_name);
X if (stat(fullname, &sb) == -1)
X {
X fprintf(stderr,"Can't stat(%s): ", fullname);
X perror("");
X continue;
X }
X
X /*
X * Ignore directories
X */
X
X if (((sb.st_mode & S_IFMT) & S_IFDIR) == S_IFDIR)
X continue;
X
X if (!strncmp(basename(fullname), "C.", 2))
X show(fullname,name);
X }
X (void) closedir(dirP);
X return (0);
X}
X
X/*
X * This is called once per C. file in the directory `dirname', which is
X * one of /usr/spool/uucp/fubar.
X * Get content of the appropriate D. files (if needed) and prepare output
X */
X
Xint show(fn, dirname)
Xchar *fn;
Xchar *dirname;
X{
X char filename[BUFSIZ];
X char *strtok(), *ptr, user[10], command[100];
X char *system = basename(dirname);
X long filesize;
X char direction;
X char buf[BUFSIZ];
X FILE *fp;
X
X if ((fp = fopen(fn,"r")) == (FILE *)0)
X {
X perror(fn);
X return (1);
X }
X
X /*
X * Read first line of C. file
X * If the second field in the first line does not begin with a
X * D. , then it is probably a uucp or uuto file, then don't read the
X * second line of the C. file.
X * In any case, get the size of the file to be transferred.
X */
X
X fgets(buf,BUFSIZ,fp);
X filesize = length(dirname, buf);
X
X if (!strncmp(buf + 2, "D.", 2))
X fgets(buf,BUFSIZ,fp);
X
X /*
X * First field contains the Send or Receive indicator
X */
X
X ptr = strtok(buf," \t");
X if (*ptr == 'S')
X direction = SEND;
X else
X direction = RECEIVE;
X
X /*
X * Get name of D. file to be sent. If the name does not start with
X * a D. , then it must be a full pathname for uucp or uuto.
X */
X
X ptr = strtok(NULL," \t");
X if (!strncmp(ptr,"D.",2))
X {
X sprintf(filename,"%s/%s", dirname, ptr);
X
X if (verbose)
X fprintf(stderr,"Looking at [%s]\n", filename);
X getcontent(filename, user, command);
X }
X else
X {
X strcpy(command, ptr);
X ptr = strtok(NULL," "); /* Dest file */
X strcat(command, " => ");
X strcat(command,ptr);
X
X ptr = strtok(NULL," "); /* Sender */
X strcpy(user, ptr);
X }
X
X printf("%-2.2s %-8.8s %-8.8s %6ld %-.52s\n",
X (direction == SEND) ? "->" : "<-",
X system, user,
X (direction == SEND) ? filesize : -1L,
X command);
X
X fclose(fp);
X return (0);
X}
X
Xchar *basename(fn)
Xchar *fn;
X{
X static char *ptr;
X
X return (ptr = (ptr = strrchr(fn,'/')) ? ++ptr : fn);
X}
X
X/*
X * Parse content of the D. files that contain requests to the remote
X * system. (This D. file will be made into an X. file on the other side)
X */
X
Xint getcontent(fn, user, command)
Xchar *fn, *user, *command;
X{
X FILE *fp;
X char buf[BUFSIZ], *ptr, *strtok();
X int c;
X
X if ((fp = fopen(fn,"r")) == (FILE *)0)
X {
X perror(fn);
X return;
X }
X
X while (fgets(buf,BUFSIZ,fp) != (char *)0)
X {
X buf[strlen(buf) - 1] = EOS;
X switch (*buf)
X {
X case 'U': /* User */
X ptr = strtok(buf," ");
X strncpy(user,strtok(NULL," "), 8);
X break;
X case 'C': /* Command */
X strncpy(command,buf + 2, 90);
X break;
X default:
X continue;
X }
X }
X
X fclose(fp);
X}
X
X/*
X * Return length in bytes of file `s' in directory `dirname'. If `s' is not
X * one of type D., then return length of the absolute pathname `s'
X */
X
Xlong length(dirname,s)
Xchar *dirname; /* /usr/spool/uucp/system */
Xchar *s; /* First line of C. file */
X{
X char buf[BUFSIZ], *ptr, *strtok();
X char filename[BUFSIZ];
X struct stat sb;
X
X strcpy(buf,s);
X
X ptr = strtok(buf," ");
X ptr = strtok(NULL," ");
X
X if (!strncmp(ptr,"D.", 2))
X sprintf(filename,"%s/%s", dirname, ptr);
X else strcpy(filename,ptr);
X if (stat(filename, &sb) == -1)
X return (-1L);
X
X else return (sb.st_size);
X}
END_OF_FILE
if test 6122 -ne `wc -c <'uushow.c'`; then
echo shar: \"'uushow.c'\" unpacked with wrong size!
fi
# end of 'uushow.c'
fi
if test -f 'uushow.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'uushow.h'\"
else
echo shar: Extracting \"'uushow.h'\" \(1204 characters\)
sed "s/^X//" >'uushow.h' <<'END_OF_FILE'
X/*
X * Copyright 1991, Jan-Piet Mens
X * License to freely use and distribute this software is hereby granted
X * by the author, subject to the condition that this copyright notice
X * remains intact. The author retains the exclusive right to publish
X * derivative works based on this work, including, but not limited
X * to, revised versions of this work
X */
X
X/*
X * $Id: uushow.h,v 1.1 1991/08/09 07:01:50 jpm Exp jpm $
X *
X * $Log: uushow.h,v $
X * Revision 1.1 1991/08/09 07:01:50 jpm
X * Initial revision
X *
X */
X
X#include <stdio.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <dirent.h>
X
X#define SPOOL "/usr/spool/uucp"
X#define SYSNAMELEN 10 /* Length of uucp systemname */
X
X#ifndef TRUE
X# define TRUE (1)
X# define FALSE (0)
X#endif
X
X#define EOS '\0'
X#define SEND 1 /* UUCP direction */
X#define RECEIVE 2
X
X#if defined(__STDC__) || defined(__cplusplus)
X# define P_(s) s
X#else
X# define P_(s) ()
X#endif
X
Xint main P_((int argc, char **argv));
Xint parse P_((char *sysname));
Xint checkup P_((char *name));
Xint show P_((char *fn, char *dirname));
Xchar *basename P_((char *fn));
Xint getcontent P_((char *fn, char *user, char *command));
Xlong length P_((char *dirname, char *s));
X
X#undef P_
END_OF_FILE
if test 1204 -ne `wc -c <'uushow.h'`; then
echo shar: \"'uushow.h'\" unpacked with wrong size!
fi
# end of 'uushow.h'
fi
echo shar: End of archive 1 \(of 1\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have the archive.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
--
Jan-Piet Mens, Logix GmbH j...@logixwi.UUCP
Moritzstr. 50, D-6200 Wiesbaden ...!uunet!mcsun!unido!logixwi!jpm

0 new messages