#!/usr/bin/perl -w
use strict ;

=head1 sched_validate_job

A complete network system schedule solution

=head2 DESCRIPTION

This program take a job file an check if we can detect error.

=head2 USAGE

    Usage : sched_validate_job -j job 
     --help      : print this help
     --job job   : execute job

=head2 INSTALLATION

Complete installation details are in the README and README.conf files included
with the software. It works with library available on CPAN.

=head2 AUTHOR

(C) 2004-2005 Eric Bollengier

You may reach me through the contact info at eric@eb.homelinux.org

=head2 LICENSE

    sched_validate_job, part of the network scheduling system (Sched)
    Copyright (C) 2004-2005 Eric Bollengier
        All rights reserved.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

=cut

use Sched::Job ;

my $VERSION = '$Id: sched_job_validate,v 1.1 2005/04/05 19:59:33 mcgregor Exp $' ;

$ENV{PATH} = '/bin:/usr/bin' ;

################################################################
# traitement de la ligne de commande

sub HELP_MESSAGE
{
    print "Usage : $0 -j job
    --help      : print this help
    --job job   : execute job
" ;
    exit (1) ;
}


################################################################
################	Variables	        ################

my $file_job = '';		# fichier xml du job

my $job ; 		# Sched::Job 

use Getopt::Long ;

GetOptions("job=s"    => \$file_job,
	   "help"     => \&HELP_MESSAGE) ;

if (!-r $file_job) {
    print "E : job file is not readable $!\n" ;
    HELP_MESSAGE() ;
}

Sched::init_test() ;


$job = new Sched::Job(serial => $Sched::serial, file => $file_job) ;

my $ret = $job->validate() ;

exit !$ret ;
# EOF
