#include <stdio.h>

main()
{
	FILE *fp;
	int i, mxfd;
	char host[15], mach[15], buf[1024];

	/*
	 * Open the host file.
	 */
	if ((fp = fopen("/etc/hostecn", "r")) == NULL) {
		printf("Cannot open /etc/hostecn\en");
		exit(1);
	}

	/*
	 * Now read in each host and try to ns over.
	 */
	while (fscanf(fp, "%s %s", host, mach) != EOF) {
		if ((mxfd = ns(host, "", "", "who", 0)) < 0) {
			printf("Cannot connect to %s\en", host);
			continue;
		}

		printf("%s:\en", host);

		while ((i = read(mxfd, buf, sizeof(buf))) > 0) 
			write(1, buf, i);

		close(mxfd);
	}
}
