Hi Gary,

It sounds like the telnet daemon on the host you are connecting to is
failing if you are not getting prompted for login using standard OS telnet
client. The telnet daemon could fail for any number of reasons.

If you can confirm the telnet daemon is working on the remote host and
connect to it using regular telnet client then here is a script I have that
uses Net::Telnet and generates a log of the telnet comms:

use Net::Telnet;

# Config Variables
$host = @ARGV[0];
$user = @ARGV[1];
$pass = @ARGV[2];
$secs = 10;
$command = @ARGV[3];

# debug log of data sent to host.
$dumplog = 'c:/dumplog.txt';


# debug log of data received from host.
$inputlog = 'c:/inputlog.txt';

$mode = 1;
$term = 'vt100';

# Net::Telnet object creation.
my $telnet = new Net::Telnet ( Prompt => '/\>$/',
            Telnetmode=>0,
            Timeout => $secs);
$telnet->errmode("return");

$log= $telnet->input_log($inputlog);
$dlog= $telnet->dump_log($dumplog);

# login
$telnet->open($host);
$telnet->login($user, $pass);# or die "login failed: @{[$telnet->errmsg]}";
$telnet->waitfor('/\>$/');

# execute command on remote host.
@output = $telnet->cmd( String   => $command,
                                Prompt  => '/\>/',
                                Timeout => $secs,
                                Cmd_remove_mode => $mode
         ) or die "Command failed: $!";
@output = $telnet->waitfor('/.:\>/');

#close telnet session
$telnet->close;

# print STDOUT returned from remote command.
print @output;
foreach (@output) {
 print "$_\n";
}

Hope this helps. It may not run completely for you but it should at least
generate a log file to tell you where the telnet session is failing.

Trevor Joerges
SendMIME Software
www.sendmime.com

----- Original Message ----- 
From: "Theisen, Gary" <[EMAIL PROTECTED]>
To: "'Trevor Joerges [SendMIME Software]'" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Wednesday, August 06, 2003 4:39 PM
Subject: RE: Net::Telnet on winNT problems


> Thanks for the reply Trevor,
>
> It does appear that it's a prompt issue.
> Using the 3rd party JAVA telnet client, masks the prompt type.
> So, I brought up DOS prompt and entered telnet.  Once in telnet, I type
open
> themainframe.com and it says connected....but then goes to a blank screen
> and I can type anything and enter and nothing is executed, almost like
just
> typing in notepad.
> Here's the telnet display that I have set:
> Microsoft Telnet> display
> Escape Character is 'CTRL+]'
> WONT AUTH (NTLM Authentication)
> LOCAL_ECHO on
> Sending both CR & LF
> WILL TERM TYPE
>
> Preferred Term Type is ANSI
> Microsoft Telnet>
>
> After connecting...why am I not prompted for a login?
>
>
> Using the perl script with Net::Telnet, this is what I have and It's
timing
> out on the prompt matching:
>
> use Net::Telnet;
> $telnet = new Net::Telnet ( Timeout=>10,
>                              Errmode=>'die');
>
> $telnet->open('themainframe.com');
>   print "connected...\n";
>
> $telnet->waitfor('/[\$%#>_] $/i'); # I even tried '/[\$%#>_ ] with a space
> This is where it times out.
> $telnet->print('userid');
>   print "entered username...\n";
>
> $telnet->waitfor('/password: $/i');
> $telnet->print('pass');
>   print "entered password...\n";
>
> $telnet->waitfor('/[\$%#>_] $/i');
>   print "logged in!\n";
>
> $telnet->print('who');
> $output = $telnet->waitfor('/\$ $/i');
> print $output;
>
> Any ideas?? Thanks.
>
> -----Original Message-----
> From: Trevor Joerges [SendMIME Software] [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, August 05, 2003 8:39 PM
> To: Theisen, Gary; [EMAIL PROTECTED]
> Subject: Re: Net::Telnet on winNT problems
>
>
> Net::Telnet will work great on WinNT 4.0. What is most likely happening is
> that your prompt '/\$ $/i' is being matched before you get prompted to
> login. Each command sent via Net::Tenet expects to match the prompt that
is
> returned after the command is executed.
>
> You can run Net::Telnet in debug mode to see where the telnet session is
> failing. You can store the debug data in local files. What is the prompt
you
> get when you telnet to the system? Is there any warning or proprietary
> banner that is displayed before the prompt (sometimes this can erroneously
> match your prompt regex)?
>
> Trevor Joerges
>
>
> ----- Original Message ----- 
> From: "Theisen, Gary" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, August 05, 2003 7:58 PM
> Subject: Net::Telnet on winNT problems
>
>
> > Hi all,
> >
> > I've been searching the web/lists/doc's but have yet to find an answer,
> I've
> > tried to do my homework first before posting here.
> >
> > My scenario:
> > Using winNT 4.0 box & IIS webserver using mainly PHP for scripting.  PHP
> > doesn't support (yet, so my script will call this to be PERL script)
what
> I
> > need to do which is.
> >
> > 1.  Connect to a mainframe (os/390).
> > 2.  Browse a VSAM file & extract specific data into an array.
> >
> > Very simply....at least seemingly so.  The access to the VSAM file is
the
> > key here.  I can make an FTP & telnet connections no problem.  FTP from
> PHP
> > web script & telnet from 3rd party JAVA client.
> >
> > My web script needs to call this perl script, which will work "behind
the
> > scenes" to populate the array on the local machine.
> >
> > I need to somehow open a connection to the mainframe w/o doing an FTP
> > download.  The file I'm browsing is enormous, so an FTP isn't feasible.
> > I've read that using Net:Telnet (which I have successfully
installed/made
> on
> > my NT 4 box), is very tricky on a windows box because windows doesn't
use
> a
> > "real" telnet client.
> >
> > This is my code so far:
> >
> > use Net::Telnet;
> >
> > $uID = "something"; $uPASS = "thepass";
> > $telnet = new Net::Telnet ( Timeout=>5,
> >                             Errmode=>'die',
> >                             Prompt => '/\$ $/i');
> > $telnet->open('mainframe.com');
> > $telnet->login($uID, $uPASS);
> > print $telnet->cmd('who');
> >
> > times out...says waiting for login prompt.
> >
> > What is the workaround to this?  A free windows telnet that installs
> > smoothly & can be used with Net:Telnet?
> > Has anyone actually gotten something like this to really work??
> >
> > Sorry for the long winded post....any suggestions/links to actual
working
> > tutorial??
> >
> > Thanks!!
> >
> > Gary
> >
> >
> > _______________________________________________
> > ActivePerl mailing list
> > [EMAIL PROTECTED]
> > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> >
>
>
> _______________________________________________
> ActivePerl mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
> _______________________________________________
> ActivePerl mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>


_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to