-1

i cannot install modules such as net::ssh because i do not have authorization, and other more complicated reasons - so i have to do this the old fashion way,

my $host = "box215";
my $cmd_proc = "/bin/ps -ef";
my $cmd_disk = "df -h";
my $cmd = "ssh -n -o ConnectTimeout=20 $host '$cmd_proc ; $cmd_disk' ";

is what i have so far.

i want to basically get the processes and disk space from the box and return it. however i am not sure how to handle the password prompt for the box.

user1747467
  • 89
  • 1
  • 1
  • 7
  • 1
    I think the downvote comes from someone who is skeptical that you really can't install a module. See [here](http://stackoverflow.com/q/251705/168657) and/or [here](http://stackoverflow.com/a/2980321/168657). – mob Sep 11 '13 at 15:48

3 Answers3

1

I would use a limited privilege account that authenticates to the server with a SSH key that does not require a passphrase.

http://www.paulkeck.com/ssh/

Jaryd Malbin
  • 113
  • 2
1

Perl modules can be installed locally pretty easily. This is how I do it usually.
Download and extract the CPAN module and cd into the location of Makefile.PL and execute following commands. <path> is where you have full access privileges.

perl Makefile.PL PREFIX=<path> LIB=<path>
make
make test
make install

To use the module in your Perl script just add the following in the beginning of your script

use lib '<path>';
Jean
  • 21,665
  • 24
  • 69
  • 119
1

If you really, absolutely cannot install any Perl modules, your options are significantly more limited. I'm just going to take your word for it and assume that the "other, more complicated reasons" you mention for not being able to install modules are related to your boss's life-threatening CPAN allergies or something equally dire, which are not resolved by installing locally. Here are a couple of (less than ideal) options:

  1. (Best option) Get your sys admin to set up ssh keys so you don't need to enter a password to connect to your remote host. Really you should do this even if you can use Perl modules.
  2. Use an expect script to send your password. This, of course, requires expect to be installed, which like option #1 may require a visit to your sys admin accompanied by a modicum of grovelling and/or bribery. If you go this route, here is a good tutorial (on expect, not on grovelling). But honestly, if all you're using expect for is to send your ssh password, you are introducing a lot of unnecessary complication that could be easily taken care of by setting up ssh keys (see option #1).

Notice that both options may require you to ask your sys admin for help. If he/she is already going to install/configure something, you might as well ask them to install some Perl modules (Expect.pm and Net::SSH2) for you while they're at it (unless, of course, somebody could die or become horribly disfigured as a result).

ThisSuitIsBlackNot
  • 23,492
  • 9
  • 63
  • 110