Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Using IO::Socket to login to a server

by deadpickle (Pilgrim)
on Feb 01, 2008 at 04:29 UTC ( [id://665513]=perlquestion: print w/replies, xml ) Need Help??

deadpickle has asked for the wisdom of the Perl Monks concerning the following question:

Is there a way to write a script that will login to a server using IO::Socket? The user is prompt in the terminal to enter the user name and password. The reason I ask is because the chat server resides on an academic server. In order for the chat client to communicate with the chat server it must first login to the academic server. I hope this is clear, I know it is a little weird but that is the only way I can set it up.

Replies are listed 'Best First'.
Re: Using IO::Socket to login to a server
by mifflin (Curate) on Feb 01, 2008 at 04:51 UTC
    It's hard to say without knowing the protocol.
    Is it telnet?
    If so, how about Net::Telnet
    or
    IO::Socket::Telnet
    ?
    You can pick these up on Cpan.
      I believe the protocol used is tcp. Can I send the user name to the server by just printing to the socket or is there another way?

        TCP isn't precise enough.

        Imagine two people communicating.
        They can communicate in English, in French, etc.
        They can communicate verbally, in writing, etc
        They can communicate over a phone, using snail mail, using a video, etc.

        By picking TCP, you picked something from the second line, but you still have haven't picked a language.

        Is it a Telnet server? an SSH server? HTTP? FTP? ...

Re: Using IO::Socket to login to a server
by redhotpenguin (Deacon) on Feb 01, 2008 at 05:43 UTC

    "it must first login"

    What do you mean by this? Does it need to open an ssh connection?

      The chat client will first have to connect to the academic server and establish a connection with that server before it can login to the chat server (which is running on the academic server).
      I tried using "use Net::SSH::Perl" and adding this code line to connect to the server using ssh:
      sub server { my $ssh = Net::SSH::Perl->new($host); $ssh->login('uas'); &init_connect; }
      and got this error in the terminal:
      *** unhandled exception in callback: *** The getpwuid function is unimplemented at C:/Perl/site/lib/Net/SSH/Perl.pm line 110. *** ignoring at C:\Documents and Settings\Jamie\Desktop\simple-client.pl line 7 0.
      a password should not be needed since its using a authentication key. I should also note that the chat client connects to the chat server using IO::Socket::INET.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://665513]
Approved by ikegami
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-03-29 07:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found