Remote Info Gathering with Perl

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
condor
Posts: 1
Joined: Tue Nov 20, 2007 1:11 pm
Location: Modesto, CA

Remote Info Gathering with Perl

Post by condor »

This is a simple script to remotely log onto another box using Perl.

Net::SSH::Perl module is needed (with whatever else it wants for your system. Use perl -MCPAN -e shell to install -it will prompt you.

I found this on the perl how-to site, and it has been useful to go get information off remote machines (frequently by running shell scripts I wrote to do various analytics).

#!/usr/bin/perl

use Net::SSH::Perl;

my $host = "perlhowto.com";
my $user = "user";
my $password = "password";

#-- set up a new connection
my $ssh = Net::SSH::Perl->new($host);
#-- authenticate
$ssh->login($user, $pass);
#-- execute the command
my($stdout, $stderr, $exit) = $ssh->cmd("ls -l /home/$user");


See:

http://www.perlhowto.com/execute_comman ... _using_ssh
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests