Subversion Repositories camp_sysinfo_client_3

Rev

Rev 85 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 85 Rev 154
Line 31... Line 31...
31
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32
#    GNU General Public License for more details.
32
#    GNU General Public License for more details.
33
#
33
#
34
#    You should have received a copy of the GNU General Public License
34
#    You should have received a copy of the GNU General Public License
35
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
35
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
 
36
#
-
 
37
#    20200215 RWR
-
 
38
#    Modified it so it will create a filename containing report date, client name, machine name and serial number
36
 
39
 
37
use warnings;
40
use warnings;
38
use strict;
41
use strict;
39
 
42
 
40
our $VERSION = '1.0';
43
our $VERSION = '1.1.0';
41
 
44
 
42
use Data::Dumper;
45
use Data::Dumper;
43
 
46
 
44
sub writeFile {
47
sub writeFile {
45
   my ( $filename, $contents ) = @_;
48
   my ( $filename, $contents ) = @_;
Line 50... Line 53...
50
      print "Could not write to $filename: $!";
53
      print "Could not write to $filename: $!";
51
      return 0;
54
      return 0;
52
   }
55
   }
53
}
56
}
54
 
57
 
55
sub filename {
58
sub makeFileName {
56
   my $dirname = shift;
59
   my $parameters = shift;
-
 
60
   my $filename = join( '_', ( $$parameters{'report date'}, $$parameters{'client name'}, $$parameters{'host name'}, $$parameters{'serial number'} ) );
57
   $dirname = '/tmp' unless $dirname;
61
   $filename .= '.sysinfo';
58
   return "$dirname/" . time . '.sysinfo';
62
   return $filename;
59
}
63
}
60
 
64
 
-
 
65
 
61
sub doit {
66
sub doit {
62
   my ( $parameters, $message ) = @_;
67
   my ( $parameters, $message ) = @_;
63
   $$parameters{'output directory'} = '/tmp' unless $$parameters{'output directory'};
68
   $$parameters{'output directory'} = '/tmp' unless $$parameters{'output directory'};
-
 
69
   `mkdir -p $$parameters{'output directory'}` unless -d $$parameters{'output directory'};
-
 
70
   $$parameters{'filename'} = &makeFileName( $parameters) unless $$parameters{'filename'};
64
 
71
 
65
   &writeFile( &filename( $$parameters{'output directory'} ), $message ); # make a backup copy of the report
72
   &writeFile( $$parameters{'output directory'} . '/' . $$parameters{'filename'}, $message ); # make a backup copy of the report
66
   return 1;
73
   return 1;
67
}
74
}
68
 
75
 
69
1;
76
1;
70
 
77
 
71
 
78
 
72
# 
-