Telnet Problem

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hi All,

I am a new bee to perl, do not know even the basics of perl.

The Scenirion, why i choose perl

I have a exe file compiled with cygwin, need to execute in different
windows machine and get the output as log files, so i chose perl to ftp
the required exe file and execute using the Telnet module. I am having
problem with Telnet as it is not returning after the completion of the
exe, it waits until the time out.

Please find the following perl code

#!/usr/bin/perl -w
use Net::Telnet;
use strict;

my $LOG_FILE="C:\Temp\Telnet.log";
my $SOURCE_PATH="C:\\SMIProviderInstallation\\src";
my $BUFFER_MAX=10485760; #10 MB of Buffer
if (($#ARGV+1)==5)
    #my $tel_obj = new Net::Telnet (Timeout => 999, errmode => 'die',
Binmode =>0);
    my $tel_obj = new Net::Telnet (errmode => 'return', Binmode =>0);
        print "Unable to telnet...\n";
        return 0;

    print "\nINFORMATION: Connecting to Host : $ARGV[1]";
    $tel_obj->login(Name => $ARGV[2], Password => $ARGV[3]);
    #$tel_obj->login($ARGV[2], $ARGV[3]);
    $tel_obj->cmd(String => "cd $SOURCE_PATH");

    print "\nINFORMATION: Executing the exe : $ARGV[4]";
    my $cmd_str = "perl $ARGV[4]";

    print "\nINFORMATION: Closing the connection with Host : $ARGV[1]";
    print "\nERROR: Invalid Argument Passed...\n";

It will get four parameters

$ARGV[0] = passing a string - variable currently not used
$ARGV[1] = Host name
$ARGV[2] = User name
$ARGV[3] = Password
$ARGV[4] = script name

the script which needs to be executed contains the following lines

#!/usr/bin/perl -w
system ("execute.exe");
print "\n$?"

Thanks in advance....

Re: Telnet Problem a écrit :
Quoted text here. Click to load it
I did not use Telnet, but i have a litttle experience in FTP.
To be able to log FTP action in the script, I have redirected STDERR,
and STDOUT in the same file. You can try this ..
open ( STDERR ,">>$LOG");
open (STDOUT ,">>$LOG");

select STDERR  ;
close (STDERR);
close (STDOUT);

Quoted text here. Click to load it

Site Timeline