static int sleepcmd(FILE *input, BSOCK *UA_sock);
-#define CONFIG_FILE "./console.conf" /* default configuration file */
+#define CONFIG_FILE "./bconsole.conf" /* default configuration file */
static void usage()
{
fprintf(stderr, _(
"\nVersion: " VERSION " (" BDATE ") %s %s %s\n\n"
-"Usage: console [-s] [-c config_file] [-d debug_level] [config_file]\n"
+"Usage: bconsole [-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"
JCR jcr;
init_stack_dump();
- my_name_is(argc, argv, "console");
+ my_name_is(argc, argv, "bconsole");
textdomain("bacula-console");
init_msg(NULL, NULL);
working_directory = "/tmp";
while ((ch = getopt(argc, argv, "bc:d:r:st?")) != -1) {
switch (ch) {
- case 'c': /* configuration file */
- if (configfile != NULL) {
- free(configfile);
- }
- configfile = bstrdup(optarg);
- break;
+ case 'c': /* configuration file */
+ if (configfile != NULL) {
+ free(configfile);
+ }
+ configfile = bstrdup(optarg);
+ break;
- case 'd':
- debug_level = atoi(optarg);
- if (debug_level <= 0) {
- debug_level = 1;
- }
- break;
+ case 'd':
+ debug_level = atoi(optarg);
+ if (debug_level <= 0) {
+ debug_level = 1;
+ }
+ break;
- case 's': /* turn off signals */
- no_signals = TRUE;
- break;
+ case 's': /* turn off signals */
+ no_signals = TRUE;
+ break;
- case 't':
- test_config = TRUE;
- break;
+ case 't':
+ test_config = TRUE;
+ break;
- case '?':
- default:
- usage();
+ case '?':
+ default:
+ usage();
}
}
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);
}
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;