#!/usr/bin/env perl use strict; use warnings; my $conffile = '/etc/nagios/forcecommand.cfg'; my %commands; my $input = $ENV{'SSH_ORIGINAL_COMMAND'} or die("No command\n");; open(my $conf, '<', $conffile) or die("Can't open $conffile: $!\n"); while (my $line = <$conf>) { my ($key, $value) = split(/ \s* = \s* /x, $line); if ($key and $value) { $commands{$key} = $value; } } close($conf) or die("Cannot close $conffile: $!\n"); if (exists $commands{$input}) { exec($commands{$input}); } exit 1;