LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-06-2003, 01:00 PM   #1
mrPhantastik
LQ Newbie
 
Registered: Aug 2003
Posts: 17

Rep: Reputation: 0
Net::Telnet


anybody know how to use Net::Telnet ??

I'm looking to connect to port 4501 (eXtremail)
but, I don't know the Prompt & what, if anything can be input, or output..


Thanks in Advance.
 
Old 09-08-2003, 04:08 AM   #2
jinksys
Member
 
Registered: Aug 2003
Location: 63123
Distribution: OpenSuSE/Ubuntu
Posts: 419

Rep: Reputation: 35
Are you asking how to use the Net::Telnet module itself or how to use it to interact with telnet services?
 
Old 09-08-2003, 07:10 AM   #3
bwMarkus
LQ Newbie
 
Registered: Aug 2003
Posts: 13

Rep: Reputation: 0
This is what I found, worked some years ago (perhaps Net::Telnet changed since then).
But I'm not sure if your app is really controllable via telnet.

#!/usr/bin/perl -w

use strict;
use Net::Telnet ();

my $t = new Net::Telnet (Timeout => 10);
$t->open("pc");
$t->login("user", "pwd");
my @lines = $t->cmd("/usr/bin/who");
print @lines;

This one is a little bit more complex, I used it to control winamp via a telnet-like plugin:

use Net::Telnet ();

$host = "rs6387";
$cmd1 = "setvol 255 ";
$cmd2 = "setvol 100";
$delay1 = 1;
$delay2 = 15;

$tries = 0;
undef $t;

while( !$t )
{
$t = new Net::Telnet( Host => $host, Timeout => 5, Port => 3200, Errmode => 'return' );

if( ! $t )
{
print "ischgriegdisch (" . $tries++ . ")\r";
sleep( 5 );
}

}

print "\n\n";

system( "net send ...." );
system( "net send ...." );

$t->prompt( '/done./' );

$t->cmd( "isplaying" );
$lastcmd = $t->lastline();

print "$lastcmd\n";

if( $lastcmd =~ /Playing/ )
{
print "Läuft bereits\n";
}
if( $lastcmd =~ /Paused/ )
{
print "sende pause-Kommando\n";
$t->cmd( "pause" );
}
if( $lastcmd =~ /not playing/ )
{
print "sende play-Kommando\n";
$t->cmd( "play" );
}
# letzte Chance ...
if( !( $lastcmd =~ /Playing/ ) )
{
$t->cmd( "play" );
}



while( 1 )
{
@lines = $t->cmd( $cmd1 );
print @lines;
sleep( $delay1 );
@lines = $t->cmd( $cmd2 );
print @lines;
sleep( $delay2 );
}

Hope this helps
 
Old 09-08-2003, 04:45 PM   #4
mrPhantastik
LQ Newbie
 
Registered: Aug 2003
Posts: 17

Original Poster
Rep: Reputation: 0
Thanks for the info to bwMarkus,

to jinksys, I'm looking to learn how to interact with telnet, truly spicifically eXtremail, but almost any telnet port will be a step in the right direction...
 
Old 09-09-2003, 12:40 PM   #5
jinksys
Member
 
Registered: Aug 2003
Location: 63123
Distribution: OpenSuSE/Ubuntu
Posts: 419

Rep: Reputation: 35
What exactly is extreme mail, is it a POP3 mail server?
Im going to need to know exactly what it is to tell you how
you should go about communicating with it. If you want to learn
how to interact with telnet servers themselves, you will need to understand how telnet works. Id go and read up the RFC on telnet.

-hope that helps
 
Old 09-10-2003, 02:58 PM   #6
mrPhantastik
LQ Newbie
 
Registered: Aug 2003
Posts: 17

Original Poster
Rep: Reputation: 0
eXtremail is a POP/SMTP server, I know a good amout about telnet in general, but eXtremail & oping ports & communicating is new to me with perl. Plus I've recently found a script written in PHP that I'm currently taring apart that does the same thing

Thanks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i install net-Telnet Whiteghost Linux - General 1 10-10-2005 10:27 AM
Using Perl NET::TELNET module DannyM Linux - Networking 4 02-15-2005 11:31 AM
Net::Telnet question on perl. mosh Programming 3 08-10-2004 09:43 AM
How do I setup telnet on Fedorac1 so I can telnet to it from winxp? mman49 Fedora 6 05-02-2004 12:40 PM
can not telnet localhost 25 but telnet dowell.exper.dynserv.com 25 exper Linux - Software 0 02-25-2004 05:13 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration