Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Open a telnet session with login using batch script

by sago (Scribe)
on Aug 14, 2008 at 05:17 UTC ( [id://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

Replies are listed 'Best First'.
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 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!

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 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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-19 06:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found