Plugin to simulate a user login?

Stanley Hopcroft Stanley.Hopcroft at IPAustralia.Gov.AU
Sat May 29 03:33:13 CEST 2004


Dear Gentlemen,

On Fri, May 28, 2004 at 05:41:59PM -0700, nagios-users-request at lists.sourceforge.net wrote:
> 
> Message: 21
> Subject: Re: [Nagios-users] Plugin to simulate a user login?
> To: "Steve Gilbert" <SGilbert at nvidia.com>
> Cc: nagios-users at lists.sourceforge.net,
> 	nagios-users-admin at lists.sourceforge.net
> From: mshirley at ysi.com
> Date: Sat, 29 May 2004 17:03:13 -0400
> 
> 
> expect expect expect expect=2E  if you need help writing one just let m=
> e know
> off list but imho this is the only way to do what you need to do
> (properly)=2E
>

You could also try the Perl modules

Net::Telnet

or

Expect.

>From the POD of Net::Telnet

'
Here's an example that prints who's logged-on to the remote host sparky.  
In addition to a username and password, you must also know the user's
shell prompt, which for this example is bash$

           use Net::Telnet ();
           $t = new Net::Telnet (Timeout => 10,
                                 Prompt => '/bash\$ $/');
           $t->open("sparky");
           $t->login($username, $passwd);
           @lines = $t->cmd("/usr/bin/who");
           print @lines;
'

The advantages of these methods over TCL/Expect is that run time errors
are caught instead of continuing to propogate garbage. Also in more
elabourate applications the TCL quoting of RegExp is incomprehensible
(add another \ there pal; no, one more). 

Expect/autoexpect is very fast to get going but hard to live with (ie
doesn't do what you expect when there's a problem).

Yours sincerely.


-- 
------------------------------------------------------------------------
Stanley Hopcroft
------------------------------------------------------------------------

'...No man is an island, entire of itself; every man is a piece of the
continent, a part of the main. If a clod be washed away by the sea,
Europe is the less, as well as if a promontory were, as well as if a
manor of thy friend's or of thine own were. Any man's death diminishes
me, because I am involved in mankind; and therefore never send to know
for whom the bell tolls; it tolls for thee...'

from Meditation 17, J Donne.


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list