.SH SYNOPSIS
.B crontab
.RB [ -u
-.IR user ] " file"
+.IR user ]
+.RI < "file"
+.RB | \ - >
.br
.B crontab
.RB [ -u
.IR user ]
-.RB [ -l " | " -r " | " -e ]\ [ -i ]
+.RB < -l " | " -r " | " -e >\ [ -i ]
.RB [ -s ]
.br
.B crontab
-.BR -n\ [
+.BR -n \ [
.IR "hostname " ]
.br
.B crontab
.SH "OPTIONS"
.TP
.B "\-u"
-Appends the name of the user whose crontab is to be modified. If this
+Specifies the name of the user whose crontab is to be modified. If this
option is not used,
.I crontab
examines "your" crontab, i.e., the crontab of the person executing the
-command. Note that
-.BR su (8)
-may confuse
-.IR crontab ,
-thus, when executing commands under
-.BR su (8)
-you should always use the
-.B -u
-option. If no crontab exists for a particular user, it is created for
+command. If no crontab exists for a particular user, it is created for
him the first time the
.B crontab -u
command is used under his username.
.SH STANDARDS
The
.I crontab
-command conforms to IEEE Std1003.2-1992 (``POSIX''). This new command
+command conforms to IEEE Std1003.2-1992 (``POSIX'') with one exception:
+For replacing the current crontab with data from standard input the
+.B \-
+has to be specified on the command line. This new command
syntax differs from previous versions of Vixie Cron, as well as from the
classic SVR3 syntax.
.SH DIAGNOSTICS
int main(int argc, char *argv[]) {
int exitstatus;
- char n[] = "-"; /*set the n string to - so we have a valid string to use */
- char *nargv[] = { argv[0], n, NULL };
if ((ProgramName=strrchr(argv[0], '/')) == NULL) {
ProgramName = argv[0];
#if defined(BSD)
setlinebuf(stderr);
#endif
- /*should we desire to make changes to behavior later. */
- if (argv[1] == NULL) { /* change behavior to allow crontab to take stdin with no '-' */
- argv = nargv;
- }
parse_args(argc, argv); /* sets many globals, opens a file */
check_spool_dir();
if (!allowed(RealUser, CRON_ALLOW, CRON_DENY)) {
endpwent();
- if (Option == opt_hostset && argv[optind] != NULL) {
+ if (Option == opt_hostset && argv[optind] != NULL) {
HostSpecified = 1;
if (strlen(argv[optind]) >= sizeof Host)
usage("hostname too long");
}
else {
if (argv[optind] != NULL) {
+ fprintf(stderr, "optind argv[optind]:%d %s\n", optind, argv[optind]);
Option = opt_replace;
if (strlen(argv[optind]) >= sizeof Filename)
usage("filename too long");
(void) strcpy(Filename, argv[optind]);
}
else
- usage("file name must be specified for replace");
+ usage("file name or - (for stdin) must be specified for replace");
}
if (Option == opt_replace) {