[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: remote login



Howdy,
	Here is something that might work for you.  Not sure if this is
what you need though . . .

#!/usr/sbin/perl

user Socket;

$rhost = 127.0.0.1;
$rport = 23;

$username = foo;
$password = bar;
$rcommand = /usr/bin/check_for_errors;

socket(SERVER, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
$iaddr = inet_aton($rhost);
$paddr = sockaddr_int($rport, $iaddr);
connect(RHOST, $paddr);
print RHOST "$username\r";
print RHOST "$password\r";
print RHOST "$rcommand\r";
@response = <RHOST>'
close(RHOST);


. . . that might not be what you need but, it might even work.  I dunno, I
don't like to test things and I am too lazy to write error checking right
now.  Although, I would recommend error checking and also to issue the
full path to whatever command you decide to run.  Just makes things easier
in the long run.  :)  Have a good one.

Tighe

ps.  I personally would you expect for this, because like Chester said, it
was made for this.

>Date: Tue, 1 Jan 2002 19:46:19 -0600
>From: Chester Langin <chester@langin.com>
>Reply-To: silug-discuss@silug.org
>To: silug-discuss@silug.org
>Subject: Re: remote login
>
>Thanks for you your question.  I was beginning to think that
>all e-mail was shut down for the Holidays :-)
>
>If you have access to ssh, then you can do this without 
>usernames and passwords, in which case, I guess perl would
>be fine.
>
>However, expect was written for this very purpose.  It is
>The Right Tool for the Job.
>
>I wrote code for a "booster" system that dynamically starts
>a number of programs on remote systems.  I used C++ code
>which includes a way to privately get a password and pass
>it to an expect script.  It is at...
>
><http://cb0.cs.siu.edu/clusterb/boostercpp.html>
>
>The expect script is revealed and explained at...
>
><http://cb0.cs.siu.edu/clusterb/boosterexp.html>
>
>That said, I'm sure somebody now will explain how to do it
>easier with perl  :-)
>
>On Tue, Jan 01, 2002 at 06:16:37PM -0600, frog@intertek.net wrote:
>> I need to look for errors on a remote server,  I'd like to use a Perl
>> script because that's what I'm trying to learn. Do I have to call an
>> expect script to handle the login an d password prompts?
>> 
>> 
>> -
>> To unsubscribe, send email to majordomo@silug.org with
>> "unsubscribe silug-discuss" in the body.
>
>,,Chester Langin,,,,,,,,,,,,,,,,,,,,,,,,,,,,
><http://cb0.cs.siu.edu> <chester@langin.com>
>~~~~~~~~~~~~~~~~~misquote of famous person~~
>
>-
>To unsubscribe, send email to majordomo@silug.org with
>"unsubscribe silug-discuss" in the body.
>

-- 
Tighe Schlottog		Sys Admin at large	  /emry\"@"/accessus.net\
                             ook ook

-----BEGIN GEEK CODE BLOCK-----
VERSION: 3.1 http://www.geekcode.com
GIT/GS d-- s:++ a-- C++++ UL++++$ US++++$ UB+++$ UO+++$ P+++>++++$ L+++>
++++$ E--- W- N++ w--- V PS+ PE Y++ PGP++ t+ 5++ X++ R+++ tv+
b+++ DI++++ D++ G++ e++>+++ h--- r++ y**
------END GEEK CODE BLOCK------


-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.