Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Open a telnet session with login using batch script

by sago (Scribe)
on Aug 14, 2008 at 05:17 UTC ( #704284=perlquestion: print w/ replies, xml ) Need Help??
sago has asked for the wisdom of the Perl Monks concerning the following question:


I want to open a telnet session with server name XYZ , port number XXXX, username YYYY and password ZZZZZ using batch script.

I executed the below commands in command prompt
telnet
open XYZ XXXX
login as YYYY and password as ZZZZZ

But when executed the same commands in batch script, only the telnet session opens,remaining things are not executed.

can anybody help me in this instance.I need to complete this batch script by today.

Comment on Open a telnet session with login using batch script
Re: Open a telnet session with login using batch script
by thezip (Vicar) on Aug 14, 2008 at 05:42 UTC

    Hello sago,

    Is this a actually Perl script? If so, what Perl code have you already written so that we may have the opportunity to debug it?

    If not, well then the question is off-topic for PerlMonks and should be asked at a more appropriate venue.


    Your wish is my commandline.
Re: Open a telnet session with login using batch script
by Lawliet (Curate) on Aug 14, 2008 at 06:21 UTC

    Wrong website to be asking that question >.<. However, I am sure there are plenty of monks who will still help you with the problem.

    I'm so adjective, I verb nouns!

    chomp; # nom nom nom

Re: Open a telnet session with login using batch script
by jethro (Monsignor) on Aug 14, 2008 at 11:32 UTC

    Without showing us the script you used, our only recourse is to use random guessing what you did

    My guess is that you just printed YYYY and ZZZZZ on STDOUT and that didn't work because STDOUT of the script is not connected to STDIN of the script.

    To do that you either use the module Expect (which is a general solution for scripts to call interactive command line programs, or Net::Telnet which is tailored especially to telnet communication. You can find both modules either in your local perl library or on CPAN

Re: Open a telnet session with login using batch script
by lorn (Monk) on Aug 14, 2008 at 15:09 UTC

    If you try CPAN first, you will find this: Net::Telnet

    Telnet with SMTP server example:

    use strict; use warnings; use Net::Telnet (); my $t = new Net::Telnet (Timeout => 10, Port => 25); $t->open("192.168.0.25"); my $foo = $t->getline; print $foo; $t->print("HELO darkstar"); $foo = $t->getline; print $foo;

    Remember CPAN is your friend!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2014-07-28 05:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (186 votes), past polls