#!/bin/sh

#
# setcrontab
# Copyright (C) 1996,2012  Free Software Foundation, Inc.
# $Id: setcrontab,v 1.2 2002/01/03 04:35:18 johnh Exp $
#

usage () {
	cat <<END
usage: $0 newcrontabfile

Sets the users crontab to whatever's given in stdin.
Works around the dumb (only interactive) crontab -e interface.
END
	#' 
}

TMP=/tmp
FE=$TMP/$$.fakeeditor
NCT=$1

trap 'rm -f $FE $NCT; exit 1' 1 2 15

# stdin to the crontab

cat >$FE <<END
#!/bin/sh
cat $NCT >\$1
exit 0
END

chmod 0700 $FE
EDITOR=$FE
VISUAL=$FE
export EDITOR VISUAL

crontab -e

rm -f $FE $NCT
exit 0

