#!/usr/local/bin/perl -w #-*-perl-*- # # # use strict; use Win32; use Getopt::Std; use vars qw ( %Option ); my ($VERSION) = '$Revision: 1.0 $' =~ /([.\d]+)/; my $warnings = 0; # Print a usuage message on a unknown option. $SIG {__WARN__} = sub { if (substr ($_ [0], 0, 14) eq "Unknown option") {die "Usage"}; require File::Basename; $0 = File::Basename::basename ($0); $warnings = 1; warn "$0: @_"; }; $SIG {__DIE__} = sub { require File::Basename; $0 = File::Basename::basename ($0); if (substr ($_ [0], 0, 5) eq "Usage") { die < 0; my $Server = ""; if ( $Option{'a'} ) { Win32::AbortSystemShutdown ( $Server ) or die "$^E\n"; exit; } my $Message = $ARGV[0]; my $Timeout = $Option{'g'} || "60"; my $ForceClose = $Option{'y'} || "0"; my $Reboot = $Option{'i'} || "5"; Win32::InitiateSystemShutdown ( $Server, $Message, $Timeout, $ForceClose, $Reboot - 5 ) or die "$^E\n"; =pod =head1 NAME B -- shut down system, change system state =head1 SYNOPSIS B [ -a ] B [ -y ] [ -g I ] [ -i I ] [ I ] =head1 DESCRIPTION B is executed by the super-user to change the state of the machine. By default, B brings the system to a state ready for power off. Before starting to shut down services and killing processes, B sends a warning message via GUI pop-up with the warning message "The systemis shutting down. Please save all work in progress and log off. Any unsaved changes will be lost. This shutdown was initiated by ..." The bottom of the window pop-up contains the custom message included in the B command. If the string contains more than one word, it should be contained within single (') or double (") quotation marks. The warning message provides output detailing the time remaining before shutdown begins. See EXAMPLES . No warning is sent to Remote Access Service (RAS) users or users connected via B or B. =head2 System state definitions =over 4 =item state 5 Shut the machine down so that it is safe to remove the power. Have the machine remove power, if possible. =item state 6 Stop the operating system and reboot without powering off. =back =head2 OPTIONS =over 4 =item -a Abort the B command. =item -y Pre-answer the confirmation question so the command can be run without user intervention. Forces running applications closed without user intervention. B - does not save data. =item -g grace-period Allow the super-user to change the number of seconds from the 60-second default. =item -i init-state If there are warnings, init-state specifies the state init is to be in. By default, system state 5 (shutdown) is used. =item -h Display syntax. =back =head1 EXAMPLES In the following example, B is being executed on host foo and is scheduled in 120 seconds C:\> shutdown -i 5 -g 120 "===== disk replacement =====" The following example aborts the above. C:\> shutdown -a =head1 ENVIRONMENT The working of B is not influenced by any environment variables. =head1 BUGS B suffers from no known bugs at this time. =head1 STANDARDS It does not make sense to talk about standards in a B manual page. =head1 REVISION HISTORY shutdown Revision 1.0 2000/06/22 06:44:57 idnopheq Initial revision =head1 AUTHOR The Perl implementation of B was written by Dexter Coffin, I. =head1 COPYRIGHT and LICENSE This program is copyright by Dexter Coffin 2000. This program is free and open software. You may use, copy, modify, distribute, and sell this program (and any modified variants) in any way you wish, provided you do not restrict others from doing the same. =head1 SEE ALSO =for html reboot

=head1 NEXT TOPIC =cut