From 31c0d40071ce40272beb6d2ff7408c707ce64847 Mon Sep 17 00:00:00 2001 From: Georg Date: Wed, 21 Jul 2021 13:47:29 +0200 Subject: Initial Scripts Run Signed-off-by: Georg --- scripts/perl/botproc.pl | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 scripts/perl/botproc.pl (limited to 'scripts/perl/botproc.pl') diff --git a/scripts/perl/botproc.pl b/scripts/perl/botproc.pl new file mode 100644 index 0000000..3ea4e9d --- /dev/null +++ b/scripts/perl/botproc.pl @@ -0,0 +1,34 @@ +#!/usr/bin/perl + +# Work in progress. +# Requires botproc.ini. + +use Config::Tiny; +use Net::OpenSSH; +use warnings; +use strict; +#use feature qw(say); + +my $config = Config::Tiny->new; +$config = Config::Tiny->read( 'botproc.ini' ); + +foreach my $section (keys %{$config}) { + my $host = "$section"; + my $OS = $config->{$section}->{OS}; + #print 'The OS of ', $host, ' is ', $OS, "\n"; + my $user = $config->{$section}->{User}; + my $keyname = $config->{$section}->{Key}; + my $keypath = "/home/georg/.ssh/" . $keyname; + my $port = $config->{$section}->{Port}; + print 'Connecting to ', $host, ':', $port, ' as ', $user, ' using key ', $keyname, "\n"; + my $ssh = Net::OpenSSH->new($host, user => $user, port => $port, key_path => $keypath); + $ssh->error and + die "FATAL: ", $ssh->error; + $ssh->system("uname -a") or + die "Remote command failed: ", $ssh->error; + my ($df, $err) = $ssh->pipe_out("df -h /") or + die "df query failed: " . $ssh->error; + print "Root Partition:\n"; + while (<$df>) { print } + close $df; +} -- cgit v1.2.3