Problems with MS Telnet Server

M

Mike

I am trying to telnet to a Windows 2K server, running the MS Services
for Unix Telnet Server.

I can connect to the box and my commands execute correctly, but I am
unable to gather the results of the commands I run. I have seen
postings online saying that the MS Telnet Server is not a "real"
telnet server and the fix for this problem is to install another
telnet server. This is not an option for me. I am stuck with this
server, and can't change it.

Can anybody help?

Here is my code. The output array is always empty, but I know the
command ran correctly. If I put the telnet module into debug and then
read the debug log, I can see the data being transfered back to my PC,
but it never gets put into the @output array. I think it has
something to do with the value of $prompt, but I have tried multiple
different ways and nothing seems to work:

##############################################################
use strict;
use Net::Telnet;

my $prompt = '/>/';

my $host = "192.168.5.2";
my $user = "user";
my $pass = "password";
my $session = Net::Telnet->new( Timeout => 30,
Prompt => $prompt,
Host => $host );
$session->login($user, $pass);

my $command = 'dumpel -l system -t';

print "About to Execute $command\n";

my @output = $session->cmd( String => $command,
Prompt => $prompt);

sleep 10;
$session->close;

print @output;
exit;
 
G

Gregory Toomey

Mike said:
I am trying to telnet to a Windows 2K server, running the MS Services
for Unix Telnet Server.

I can connect to the box and my commands execute correctly, but I am
unable to gather the results of the commands I run. I have seen
postings online saying that the MS Telnet Server is not a "real"
telnet server and the fix for this problem is to install another
telnet server. This is not an option for me. I am stuck with this
server, and can't change it.

Can anybody help?

Try expect(1) instead of Perl.

gtoomey
 
J

James Willmore

I am trying to telnet to a Windows 2K server, running the MS Services
for Unix Telnet Server.

I can connect to the box and my commands execute correctly, but I am
unable to gather the results of the commands I run. I have seen
postings online saying that the MS Telnet Server is not a "real" telnet
server and the fix for this problem is to install another telnet server.
This is not an option for me. I am stuck with this server, and can't
change it.

Can anybody help?

[...]

Check the prompt. You might want to read the section of the Net::Telnet
documentation on MS Services.

If you can change the prompt in your telnet session (meaning, if you can
log into the telnet service from the command line and change your prompt
to something like '_MYPROMPT_'), then you can do that in the script as
well. This way, you don't have to try different regular expressions out to
find the "right one" for the prompt. You'll already know what it is :)

Otherwise, the code posted works for me (with modifications - I use SuSE
and SuSE has decided that my terminal is a "network" terminal instead of a
vt100 or something "normal" ... so I have to modify the script in order
for it to work :) ).

HTH

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
You're at the end of the road again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top