#include #include #include #include store_command(cpu_nr, argc, argv) int cpu_nr, argc; char *argv[]; { int group, user; FILE *fp, *fopen(); int i, pid; int yy, mm, dd, hh, min, sec; int npar; char str[32], cline[256], tmpfile[64], pipe[64]; char *user_tubi_sitter = "tubi_sitter"; char *mktemp(); /* printf(" store_command *** called ***\n"); printf(" argc = %d \n", argc); printf(" store_command : argv[0]: %s \n", argv[0]); */ upperword(argv[0]); /* printf(" store_command : argv[0]: %s \n", argv[0]); */ if (strcmp(argv[0], "HV_SWITCH") == 0) npar = 4; else if (strcmp(argv[0], "HV_SET") == 0){ npar = 5; if (strcmp(argv[2], "full") == 0 || strcmp(argv[2], "FULL") == 0 ) npar = npar + 6; } else return 0; /* printf(" store_command : npar = %d : \n", npar); printf(" %s, %s, %s\n", argv[0], argv[1], argv[2] ); */ if (argc == npar){ if ( strcmp(argv[npar - 1], user_tubi_sitter) == 0){ group = 0; user = 100; } } else get_id(&group, &user); if (user == 100) return 0; data_ora(&yy, &mm, &dd, &hh, &min, &sec); strcpy(tmpfile, argv[0]); strcat(tmpfile, "_XXXXXX"); if ( mktemp(tmpfile) == (char *) NULL){ printf(" %s cannot create temp file name %s\n", argv[0], tmpfile); printf(" %s.log on vax not updated \n", argv[0]); return 0; } fp = fopen( tmpfile, "a+"); fprintf(fp, "%d-%d-%d %d:%d %s %s", dd, mm, yy, hh, min, argv[1], argv[2]); for ( i = 3; i < npar - 1; i++) fprintf(fp, " %s", argv[i]); fprintf(fp, " by %d.%d\n", group, user); fclose(fp); /* printf(" store_command : temp_file written\n"); */ strcpy(cline, "dagostin\n"); strcat(cline, "zeus148\n"); strcat(cline, "chd bm$hwc\n"); if (cpu_nr == 1) strcat(cline, "chd [.commands.balc1]\n"); else if (cpu_nr == 2) strcat(cline, "chd [.commands.balc2]\n"); else strcat(cline, "chd [.commands.lab]\n"); strcat(cline, "append "); strcat(cline, tmpfile); strcat(cline, " "); strcat(cline, argv[0]); strcat(cline, ".LOG\n"); strcat(cline, "quit\n"); strcpy(pipe, "/pipe/"); strcat(pipe, tmpfile); if((pid = create(pipe, 0x03 + S_ISIZE, 0x03, strlen(cline))) == -1) exit(_errmsg(errno," store_command: error creating %s\n",pipe)); write(pid, cline, strlen(cline)); /* printf(" store_command : pipe filled \n"); */ strcpy(cline, "(ftp zbmuon <"); strcat(cline, pipe); strcat(cline, " >>>/nil;"); strcat(cline, " del "); strcat(cline, tmpfile); strcat(cline, " ) &"); system(cline); /* printf(" store_command : ftp executed\n"); */ close(pid); return 0; }