From f998babc5e8e421e38f22342ee3449f5c2996ceb Mon Sep 17 00:00:00 2001 From: Marius Halden Date: Thu, 10 Nov 2016 20:23:01 +0100 Subject: Add flag to newbatch to make jobs executable --- newbatch.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/newbatch.c b/newbatch.c index 0bac7ee..45de7b9 100644 --- a/newbatch.c +++ b/newbatch.c @@ -17,16 +17,30 @@ main(int argc, char **argv) int64_t microtime; char *timestr = NULL, *queuedir = NULL, *tmpfile = NULL, *newfile = NULL; char buf[1024], *tmp; - int fd, l, m; - int perm = 0640; + int fd, l, m, ch; + int perm = 0640, exec = 0; + + while ((ch = getopt(argc, argv, "e")) != -1) { + switch (ch) { + case 'e': + exec = 1; + break; + default: + fprintf(stderr, "Usage: %s [-e] [dir]", argv[0]); + return 1; + } + } + + argc -= optind; + argv += optind; mypid = getpid(); gettimeofday(&tv, NULL); microtime = tv.tv_sec * 1000000 + tv.tv_usec; asprintf(×tr, "%li.%u", microtime, mypid); - if (argc > 1) { - queuedir = strdup(argv[1]); + if (argc >= 1) { + queuedir = strdup(argv[0]); } else { queuedir = strdup(DEFAULT_QUEUE_DIR); } @@ -36,7 +50,7 @@ main(int argc, char **argv) free(timestr); free(queuedir); - if (getenv("NEWBATCH_EXEC") != NULL) { + if (exec || getenv("NEWBATCH_EXEC") != NULL) { perm = 0750; } -- cgit v1.2.3