#!/usr/bin/perl -w use strict; my $run_crontab = 1; my @safe_argv; my ( $bForce, $bRemove, $bHelp ); foreach ( @ARGV ) { if ( uc( $_ ) eq '--FORCE' ) { $bForce = 1; } else { if ( uc( $_ ) eq '-R' ) { $bRemove = 1; } push( @safe_argv, $_ ); } } if ( $bRemove ) { unless( $bForce ) { my ( $y_or_n ); do { print 'Are you sure you want to remove the crontab? (Y/N): '; $y_or_n = uc( getc() ); print \"\n\"; } until ( ( $y_or_n eq 'Y' ) || ( $y_or_n eq 'N' ) ); if ( $y_or_n eq 'N' ) { print \"/usr/bin/crontab: no changes made to crontab\n\"; $run_crontab = 0; } } } if ( $run_crontab ) { if ( system( '/usr/bin/crontab', @safe_argv ) == 256 ) { print \"\t--force (delete crontab without prompting)\n\"; } }