diff options
author | Georg | 2021-07-21 13:47:29 +0200 |
---|---|---|
committer | Georg | 2021-07-21 13:47:29 +0200 |
commit | 16d3474327644bad618dcf5fb4548a8d52e7c2f8 (patch) | |
tree | f66b33587d4f52f5ed669a41a23273bc55edd3b8 /scripts/perl | |
parent | 2678e73ff1eb2f4e0a5d02a750ec4c047333da6b (diff) | |
download | system-16d3474327644bad618dcf5fb4548a8d52e7c2f8.tar.gz system-16d3474327644bad618dcf5fb4548a8d52e7c2f8.tar.bz2 system-16d3474327644bad618dcf5fb4548a8d52e7c2f8.zip |
Initial Scripts Run
Signed-off-by: Georg <georg@lysergic.dev>
Diffstat (limited to 'scripts/perl')
-rw-r--r-- | scripts/perl/README.md | 1 | ||||
-rw-r--r-- | scripts/perl/botproc.pl | 34 |
2 files changed, 35 insertions, 0 deletions
diff --git a/scripts/perl/README.md b/scripts/perl/README.md new file mode 100644 index 0000000..6362185 --- /dev/null +++ b/scripts/perl/README.md @@ -0,0 +1 @@ +Contains scripts designed to be executed through Perl interpreters (#!/bin/perl). 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; +} |