It is possible. There are a few things missing in your question, however: do you want to use Perl, or will a shell script suffice? are you logging onto the host using FTP, SSH, or Telnet?
Assuming that at this point you want only a proof that it can be done, here is a very, very basic example in shell.
#!/bin/bash HOST=$1 ssh root@$HOST 'bash -s' <<'ENDSSH' # commands to run on remote host echo Installing httpd yum install -y httpd echo Yum exited with status $? ENDSSH
...and in Perl.
#!/usr/bin/perl use v5.14; use Net::SSH::Perl; my ($host, $user, $pass) = @ARGV; my $ssh = Net::SSH::Perl->new($host); $ssh->login($user, $pass); my($stdout, $stderr, $exit) = $ssh->cmd('ls -ltr'); say $stdout;
regards,
Luke Jefferson
In reply to Re: Executing after logging into a remote machine
by blindluke
in thread Executing after logging into a remote machine
by srinigs
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |