"Fossies" - the Fresh Open Source Software Archive

Member "dirvish-1.2.1/dirvish-runall.pl" (19 Feb 2005, 3080 Bytes) of package /linux/privat/old/dirvish-1.2.1.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "dirvish-runall.pl" see the Fossies "Dox" file reference documentation.

    1 
    2 #       $Id: dirvish-runall.pl,v 12.0 2004/02/25 02:42:14 jw Exp $  $Name: Dirvish-1_2 $
    3 
    4 $VERSION = ('$Name: Dirvish-1_2 $' =~ /Dirvish/i)
    5     ? ('$Name: Dirvish-1_2 $' =~ m/^.*:\s+dirvish-(.*)\s*\$$/i)[0]
    6     : '1.1.2 patch' . ('$Id: dirvish-runall.pl,v 12.0 2004/02/25 02:42:14 jw Exp $'
    7         =~ m/^.*,v(.*:\d\d)\s.*$/)[0];
    8 $VERSION =~ s/_/./g;
    9 
   10 
   11 #########################################################################
   12 #                                                               #
   13 #   Copyright 2002 and $Date: 2004/02/25 02:42:14 $
   14 #                         Pegasystems Technologies and J.W. Schultz     #
   15 #                                                               #
   16 #   Licensed under the Open Software License version 2.0        #
   17 #                                                               #
   18 #   This program is free software; you can redistribute it      #
   19 #   and/or modify it under the terms of the Open Software       #
   20 #   License, version 2.0 by Lauwrence E. Rosen.         #
   21 #                                                               #
   22 #   This program is distributed in the hope that it will be     #
   23 #   useful, but WITHOUT ANY WARRANTY; without even the implied  #
   24 #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR     #
   25 #   PURPOSE.  See the Open Software License for details.        #
   26 #                                                               #
   27 #########################################################################
   28 
   29 use Time::ParseDate;
   30 use POSIX qw(strftime);
   31 use Getopt::Long;
   32 
   33 sub loadconfig;
   34 sub seppuku;
   35 
   36 sub usage
   37 {
   38     my $message = shift(@_);
   39 
   40     length($message) and print STDERR $message, "\n\n";
   41 
   42     $! and exit(255); # because getopt seems to send us here for death
   43 
   44     print STDERR <<EOUSAGE;
   45 USAGE
   46     dirvish-runall OPTIONS
   47 OPTIONS
   48     --config configfile
   49     --no-run
   50     --quiet
   51     --version
   52 EOUSAGE
   53 
   54     exit 255;
   55 }
   56 
   57 $Options = {
   58     version     => sub {
   59             print STDERR "dirvish version $VERSION\n";
   60             exit(0);
   61         },
   62     help        => \&usage,
   63 };
   64 
   65 GetOptions($Options, qw(
   66         config=s
   67         quiet no-run|dry-run
   68         version help
   69     )) or usage;
   70 
   71 if ($$Options{config})
   72 {
   73     $Config = loadconfig(undef, $$Options{config})
   74 }
   75 elsif ($CONFDIR =~ /dirvish$/ && -f "$CONFDIR.conf")
   76 {
   77     $Config = loadconfig(undef, "$CONFDIR.conf");
   78 }
   79 elsif (-f "$CONFDIR/master.conf")
   80 {
   81     $Config = loadconfig(undef, "$CONFDIR/master.conf");
   82 }
   83 elsif (-f "$CONFDIR/dirvish.conf")
   84 {
   85     seppuku 250, <<EOERR;
   86 ERROR: no master configuration file.
   87     An old $CONFDIR/dirvish.conf file found.
   88     Please read the dirvish release notes.
   89 EOERR
   90 }
   91 else
   92 {
   93     seppuku 251, "ERROR: no global configuration file";
   94 }
   95 $$Config{Dirvish} ||= 'dirvish';
   96 
   97 $$Options{'no-run'} and $$Options{quiet} = 0;
   98 
   99 $errors = 0;
  100 
  101 for $sched (@{$$Config{Runall}})
  102 {
  103     ($vault, $itime) = split(/\s+/, $sched);
  104     $cmd = "$$Config{Dirvish} --vault $vault";
  105     $itime and $cmd .= qq[ --image-time "$itime"];
  106     $$Options{quiet}
  107         or printf "%s %s\n", strftime('%H:%M:%S', localtime), $cmd;
  108     $$Options{'no-run'} and next;
  109     $status = system($cmd);
  110     $status < 0 || $status / 256 and ++$errors;
  111 
  112 }
  113 $$Options{quiet}
  114     or printf "%s %s\n", strftime('%H:%M:%S', localtime), 'done';
  115 
  116 
  117 exit ($errors < 200 ? $errors : 199);