static void usage()
{
fprintf(stderr, _(
-"\nVersion: " VERSION " (" BDATE ")\n\n"
+"\nVersion: " VERSION " (" BDATE ") %s %s %s\n\n"
"Usage: console [-s] [-c config_file] [-d debug_level] [config_file]\n"
" -c <file> set configuration file to file\n"
" -dnn set debug level to nn\n"
" -s no signals\n"
" -t test - read configuration and exit\n"
" -? print this message.\n"
-"\n"));
+"\n"), HOST_OS, DISTNAME, DISTVER);
exit(1);
}
if (stat < 0) {
break; /* error */
} else if (stat == 0) { /* timeout */
- bnet_fsend(UA_sock, ".messages");
+ if (strcmp(prompt, "*") == 0) {
+ bnet_fsend(UA_sock, ".messages");
+ } else {
+ continue;
+ }
} else {
at_prompt = FALSE;
/* @ => internal command for us */
Dmsg0(40, "Opened connection with Director daemon\n");
+ sendit(_("Enter a period to cancel a command.\n"));
+
+ char *env = getenv("HOME");
+ if (env) {
+ FILE *fd;
+ pm_strcpy(&UA_sock->msg, env);
+ pm_strcat(&UA_sock->msg, "/.bconsolerc");
+ fd = fopen(UA_sock->msg, "r");
+ if (fd) {
+ read_and_process_input(fd, UA_sock);
+ fclose(fd);
+ }
+ }
+
read_and_process_input(stdin, UA_sock);
if (UA_sock) {
if (!line) {
exit(1);
}
- strcpy(sock->msg, line);
- strip_trailing_junk(sock->msg);
- sock->msglen = strlen(sock->msg);
+ strip_trailing_junk(line);
+ sock->msglen = pm_strcpy(&sock->msg, line);
if (sock->msglen) {
add_history(sock->msg);
}
static int versioncmd(FILE *input, BSOCK *UA_sock)
{
- sendit("Version: " VERSION " (" BDATE ")\n");
+ sendit("Version: " VERSION " (" BDATE ") %s %s %s\n",
+ HOST_OS, DISTNAME, DISTVER);
return 1;
}
FILE *fd;
if (argc > 2) {
- sendit(_("Too many arguments.\n"));
- return 0;
+ sendit(_("Too many arguments on input command.\n"));
+ return 1;
}
if (argc == 1) {
- sendit(_("First argument must be a filename.\n"));
- return 0;
+ sendit(_("First argument to input command must be a filename.\n"));
+ return 1;
}
fd = fopen(argk[1], "r");
if (!fd) {
- sendit(_("Cannot open file. ERR=%s\n"), strerror(errno));
- return 0;
+ sendit(_("Cannot open file %s for input. ERR=%s\n"),
+ argk[1], strerror(errno));
+ return 1;
}
read_and_process_input(fd, UA_sock);
fclose(fd);
char *mode = "a+";
if (argc > 3) {
- sendit(_("Too many arguments.\n"));
+ sendit(_("Too many arguments on output/tee command.\n"));
return 1;
}
if (argc == 1) {
}
fd = fopen(argk[1], mode);
if (!fd) {
- sendit(_("Cannot open file. ERR=%s\n"), strerror(errno));
+ sendit(_("Cannot open file %s for output. ERR=%s\n"),
+ argk[1], strerror(errno));
return 1;
}
output = fd;