3 * Test client for update_server protocol.
5 * Copyright 1992-1998 by the Massachusetts Institute of Technology.
6 * For copying and distribution information, please see the file
10 #include <mit-copyright.h>
23 int main(int argc, char **argv)
25 char *host, *file, *rfile, *ibuf = NULL;
26 int code, i, count = 0, conn;
35 conn = mr_connect_internal(host, SERVICE_NAME);
38 com_err(whoami, errno, ": can't connect to %s:%s", host, SERVICE_NAME);
42 code = send_auth(conn, host);
44 com_err(whoami, code, "attempting authorization");
46 for (i = 2; i < argc; i++)
48 if (argv[i][0] != '-')
57 fprintf(stderr, "Sending file %s to %s as %s\n", file, host, rfile);
58 send_file(conn, file, rfile, 0);
65 fprintf(stderr, "Sending (encrypted) file %s to %s as %s\n",
67 send_file(conn, file, rfile, 1);
73 ibuf = strdup("/tmp/moira-updateXXXXX");
76 com_err(whoami, ENOMEM, "sending instructions");
80 fprintf(stderr, "Sending instructions %s to %s as %s\n",
82 send_file(conn, file, ibuf, 0);
90 fprintf(stderr, "Sending instructions %s to %s as %s\n",
92 send_file(conn, file, ibuf, 0);
97 fprintf(stderr, "No instructions sent.");
100 fprintf(stderr, "Executing instructions %s on %s\n", ibuf, host);
101 code = execute(conn, ibuf);
103 com_err(whoami, code, "executing");
109 fprintf(stderr, "Executing instructions %s on %s\n", file, host);
110 code = execute(conn, file);
112 com_err(whoami, code, "executing");
127 fprintf(stderr, "Usage: test host [commands...]\n");
128 fprintf(stderr, " Commands are:\n");
129 fprintf(stderr, "\t-s srcfile dstfile\tsends file\n");
130 fprintf(stderr, "\t-S srcfile dstfile\tsends encrypted file\n");
131 fprintf(stderr, "\t-i srcfile\t\tsends instructions\n");
132 fprintf(stderr, "\t-I srcfile dstfile\tsends instructions\n");
133 fprintf(stderr, "\t-x\t\texecutes last instructions\n");
134 fprintf(stderr, "\t-X file\t\texecutes file\n");