How to execute a command on a remote Linux host using Perl

Home > Search > How-to


use Core;

my $user = "root";
my $pass = "roots password";
my $host = "hostname of the target server";
my $command = "the command you want to run on the target server";

sub remoteCmd
     ($stdout, $stderr, $exit) = create_shell($host, $user, $pass);
     ($stdout, $stderr, $exit) = execute_shell_inline($host, $user, $command);
     my $command = $stdout;
     print $command;



Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter in the box below so that we can be sure you are a human.