summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Straz <nstraz@redhat.com>2009-10-01 10:58:42 -0400
committerNathan Straz <nstraz@redhat.com>2009-10-01 10:58:42 -0400
commitf5e388528bd8f1b6ca10a43c0f32f3fd1d3dfabe (patch)
tree433aabc7da536cb376fee4c3b94ceb8ad1b76d1f
parent8d6f3aff31e7c60b1baff013a55e34e5116abcc5 (diff)
downloadqarsh-f5e388528bd8f1b6ca10a43c0f32f3fd1d3dfabe.tar.gz
qarsh-f5e388528bd8f1b6ca10a43c0f32f3fd1d3dfabe.tar.xz
qarsh-f5e388528bd8f1b6ca10a43c0f32f3fd1d3dfabe.zip
Add quiet option, document exit status
-rw-r--r--btimec.18
-rw-r--r--btimec.c15
2 files changed, 16 insertions, 7 deletions
diff --git a/btimec.1 b/btimec.1
index 1e67389..f661498 100644
--- a/btimec.1
+++ b/btimec.1
@@ -2,7 +2,7 @@
.SH NAME
btimec \- Get the boot time of a host from btimed(8).
.SH SYNOPSIS
-\fBbtimec\fR [-\fBr\fR] \fIhost\fR [\fIhost\fR ...]
+\fBbtimec\fR [-\fBqr\fR] \fIhost\fR [\fIhost\fR ...]
.SH DESCRIPTION
.B Btimec
connects to btimed(8) on the specified \fIhost\fR to determine the time the
@@ -11,7 +11,13 @@ output. If multiple hosts are listed, the value for each host is printed on a
separate line.
.SH OPTIONS
.TP
+.B \-q
+Don't print the boot time.
+.TP
.B \-r
Print the boot time in a human readable form.
+
+.SH EXIT STATUS
+Success if the host returns a boot time, failure otherwise.
.SH "SEE ALSO"
btimed(8), qarsh(1)
diff --git a/btimec.c b/btimec.c
index f1d4518..2f791ff 100644
--- a/btimec.c
+++ b/btimec.c
@@ -29,21 +29,24 @@
#include "btime.h"
-char usage[] = "USAGE: %s [-r] <host>\n";
+char usage[] = "USAGE: %s [-qr] <host>\n";
int
main(int argc, char **argv)
{
unsigned int bt;
char *btimedhost;
- int readable = 0;
+ int readable = 1;
int c;
int ret = 0;
- while ((c = getopt(argc, argv, "r")) != -1) {
+ while ((c = getopt(argc, argv, "qr")) != -1) {
switch (c) {
+ case 'q':
+ readable = 0;
+ break;
case 'r':
- readable = 1;
+ readable = 2;
break;
default:
fprintf(stderr, usage, argv[0]);
@@ -59,11 +62,11 @@ main(int argc, char **argv)
for ( ; optind < argc; optind++) {
btimedhost = argv[optind];
bt = btime(btimedhost);
- if (readable) {
+ if (readable == 2) {
time_t tt = bt;
time_t *ttp = &tt;
printf("%s: %s", btimedhost, bt ? ctime(ttp) : "down\n");
- } else {
+ } else if (readable == 1) {
printf("%s: %u\n", btimedhost, bt);
}
if (bt == 0) ret = 1;