diff options
author | Nathan Straz <nstraz@redhat.com> | 2009-10-01 10:58:42 -0400 |
---|---|---|
committer | Nathan Straz <nstraz@redhat.com> | 2009-10-01 10:58:42 -0400 |
commit | f5e388528bd8f1b6ca10a43c0f32f3fd1d3dfabe (patch) | |
tree | 433aabc7da536cb376fee4c3b94ceb8ad1b76d1f | |
parent | 8d6f3aff31e7c60b1baff013a55e34e5116abcc5 (diff) | |
download | qarsh-f5e388528bd8f1b6ca10a43c0f32f3fd1d3dfabe.tar.gz qarsh-f5e388528bd8f1b6ca10a43c0f32f3fd1d3dfabe.tar.xz qarsh-f5e388528bd8f1b6ca10a43c0f32f3fd1d3dfabe.zip |
Add quiet option, document exit status
-rw-r--r-- | btimec.1 | 8 | ||||
-rw-r--r-- | btimec.c | 15 |
2 files changed, 16 insertions, 7 deletions
@@ -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) @@ -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; |