Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
#! /usr/bin/env perl
# Program: save_local
# Copyright (C) 2016 R. W. Rodolico
#
# Description
# Script will upload file passed on STDIN to URL defined in $server
# using variable name $urlVarName.
# Filename may also be passed on command line
# It assumes the remote server will return the exact contents which
# is then used to compare to what was sent
# It will return the following codes
# 0 - success
# 1 - Could not find LWP::Simple module
# 2 - file not passed on STDIN
# 3 - Contents returned by server do not match our local copy
# 4 - URL call returned a "not found" error
# 5 - no key given for report contents
# 6 - no key given for report date
# 7 - no key given for hostname
# 8 - no key given for client
# 9 - no key given for serial number
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
use warnings;
use strict;
our $VERSION = '1.0';
use Data::Dumper;
sub writeFile {
my ( $filename, $contents ) = @_;
if ( open FILE,">$filename" ) {
print FILE $contents;
close FILE;
} else {
print "Could not write to $filename: $!";
return 0;
}
}
sub filename {
my $dirname = shift;
$dirname = '/tmp' unless $dirname;
return "$dirname/" . time . '.sysinfo';
}
sub doit {
my ( $parameters, $message ) = @_;
$$parameters{'output directory'} = '/tmp' unless $$parameters{'output directory'};
&writeFile( &filename( $$parameters{'output directory'} ), $message ); # make a backup copy of the report
return 1;
}
1;
#
Generated by GNU Enscript 1.6.5.90.