Click here to get back home

Telnet Problem

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Telnet Problem abdur_rab7 12-08-2006
Posted by abdur_rab7 on December 8, 2006, 5:06 am
Please log in for more thread options


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);
        $tel_obj->max_buffer_length($BUFFER_MAX);
        $tel_obj->input_log($LOG_FILE);
        if(!($tel_obj->open($ARGV[1])))
        {
                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");
        $tel_obj->timeout(999);

        print "\nINFORMATION: Executing the exe : $ARGV[4]";
        my $cmd_str = "perl $ARGV[4]";
        $tel_obj->cmd($cmd_str);
        $tel_obj->timeout(0);
        $tel_obj->close;

        print "\nINFORMATION: Closing the connection with Host : $ARGV[1]";
}
else
{
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....


Posted by Olivier Mougin on December 14, 2006, 3:37 am
Please log in for more thread options


abdur_rab7@yahoo.co.in a écrit :
> 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.
>
Hello,
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);



> 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);
>         $tel_obj->max_buffer_length($BUFFER_MAX);
>         $tel_obj->input_log($LOG_FILE);
>         if(!($tel_obj->open($ARGV[1])))
>         {
>                 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");
>         $tel_obj->timeout(999);
>
>         print "\nINFORMATION: Executing the exe : $ARGV[4]";
>         my $cmd_str = "perl $ARGV[4]";
>         $tel_obj->cmd($cmd_str);
>         $tel_obj->timeout(0);
>         $tel_obj->close;
>
>         print "\nINFORMATION: Closing the connection with Host : $ARGV[1]";
> }
> else
> {
> 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....
>

Similar ThreadsPosted
net::telnet problem July 23, 2004, 6:46 pm
Problem with Net::Telnet October 20, 2005, 4:19 pm
Net:Telnet problem with print October 20, 2005, 5:04 pm
problem in telnet using perl December 27, 2007, 11:22 pm
Telnet problem -getting timed out error - April 18, 2006, 9:15 am
reading from Net::Telnet input string problem June 16, 2006, 1:17 pm
Net::Telnet retrieving temporary text problem November 6, 2006, 3:32 am
How do you telnet from 1 host to another using Telnet Module December 21, 2005, 4:15 pm
net::telnet to ms telnet server May 19, 2005, 12:28 am
Net::Telnet December 9, 2004, 11:33 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap