/* d o k e r m i t -- do a list of Kermit commands */ /* Usage: "dokermit command, command, command, ..." Encloses the command list in -C "..." and adds ", exit", invokes the real Kermit program with it, and returns the Kermit program's exit status. F. da Cruz, Colubmia University, Feb 2001. */ #include #define BUFLEN 10240 #define NUL '\0' char buf[BUFLEN] = { NUL, NUL }; main(argc,argv) int argc; char *argv[]; { int i, k, n = BUFLEN; char * s, * p = buf; argv[argc++] = ", exit\""; for (i = 0; i < argc; i++) { s = (i == 0) ? "kermit -C \"" : argv[i]; k = strlen(s); if (k < 1) continue; if (k > n) { printf("?Command too long -- %d max\n", BUFLEN); exit(1); } strncpy(p,s,k); p += k; n -= k; if (i == 0 || i == (argc - 2)) continue; if (i == (argc - 1)) break; *p++ = ' '; n--; } *p = NUL; exit(system(buf) & 0xff); }