- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- how to use URI::telnet
Operating System - HP-UX
1753632
Members
5723
Online
108798
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2010 04:44 AM
тАО07-12-2010 04:44 AM
how to use URI::telnet
Hi,
I am very new to perl. I want to know how i can make use of URI::telnet module to login to a remote host.
Any kind of help would be appreciated.
I am very new to perl. I want to know how i can make use of URI::telnet module to login to a remote host.
Any kind of help would be appreciated.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2010 05:30 AM
тАО07-12-2010 05:30 AM
Re: how to use URI::telnet
I'm not a Perl guru, but as far as I understand, the URI::telnet module will only help you in splitting the "telnet://user:password@host.name.example:port/" style URL to its component parts, not for the actual connection.
See the documentation of the URI package:
http://search.cpan.org/~gaas/URI-1.54/URI.pm
For actually connecting to a Telnet server, you'll want Net::Telnet instead. See the programming examples near the end of this web page:
http://search.cpan.org/~jrogers/Net-Telnet-3.03/lib/Net/Telnet.pm
In general, you should know that there is a lot of useful documentation available at perl.org, and in the Comprehensive Perl Archive Network (CPAN):
http://www.perl.org/
http://cpan.perl.org/
MK
See the documentation of the URI package:
http://search.cpan.org/~gaas/URI-1.54/URI.pm
For actually connecting to a Telnet server, you'll want Net::Telnet instead. See the programming examples near the end of this web page:
http://search.cpan.org/~jrogers/Net-Telnet-3.03/lib/Net/Telnet.pm
In general, you should know that there is a lot of useful documentation available at perl.org, and in the Comprehensive Perl Archive Network (CPAN):
http://www.perl.org/
http://cpan.perl.org/
MK
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2010 08:49 AM
тАО07-12-2010 08:49 AM
Re: how to use URI::telnet
Hi:
As Matti said, if you actually want to login to a remote host to perform some work, you want the 'Net::Telnet' module and not the 'URI::telnet' one. A simple example might be:
# cat ./mytelnet
#!/usr/bin/perl
use strict;
use warnings;
use Net::Telnet;
die "'Host' 'User' 'Pass' expected\n" unless @ARGV == 3;
my ( $host, $user, $pass ) = ( shift, shift, shift )
or die "Host User Pass expected\n";
my $telnet = new Net::Telnet;
$telnet->open($host);
$telnet->login( $user, $pass );
print $telnet->cmd('uname -a'), "\n"; #...print to tty directly...
$telnet->print("bdf");
my ($output) = $telnet->waitfor('/[\$%#>] $/'); #...capture first...
print $output;
$telnet->close;
print "\n\n";
1;
...run as:
# ./mytelnet myserver mylogin mypassword
Be aware that anyone looking at the process table (with 'ps' for example) would see the cleartext password in the runtime arguments. Then of course, Telnet itself isn't secure either ;-)
Regards!
...JRF...
As Matti said, if you actually want to login to a remote host to perform some work, you want the 'Net::Telnet' module and not the 'URI::telnet' one. A simple example might be:
# cat ./mytelnet
#!/usr/bin/perl
use strict;
use warnings;
use Net::Telnet;
die "'Host' 'User' 'Pass' expected\n" unless @ARGV == 3;
my ( $host, $user, $pass ) = ( shift, shift, shift )
or die "Host User Pass expected\n";
my $telnet = new Net::Telnet;
$telnet->open($host);
$telnet->login( $user, $pass );
print $telnet->cmd('uname -a'), "\n"; #...print to tty directly...
$telnet->print("bdf");
my ($output) = $telnet->waitfor('/[\$%#>] $/'); #...capture first...
print $output;
$telnet->close;
print "\n\n";
1;
...run as:
# ./mytelnet myserver mylogin mypassword
Be aware that anyone looking at the process table (with 'ps' for example) would see the cleartext password in the runtime arguments. Then of course, Telnet itself isn't secure either ;-)
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2010 12:59 PM
тАО07-12-2010 12:59 PM
Re: how to use URI::telnet
Hi:
I should add that using a '.netrc' file helps hide the password somewhat.
# cat ./mytelnet
#!/usr/bin/perl
use strict;
use warnings;
use Net::Netrc;
use Net::Telnet;
die "'host' 'login' expected\n" unless @ARGV == 2;
my ( $host, $login ) = ( shift, shift ) or die "Host User Pass expected\n";
my ( $machine, $pass, $acct );
if ( $machine = Net::Netrc->lookup( $host, $login ) ) {
( $login, $pass, $acct ) = $machine->lpa();
}
else {
die "No matching '.netrc' entry found\n";
}
my $telnet = new Net::Telnet;
$telnet->open($host);
$telnet->login( $login, $pass );
print $telnet->cmd('uname -a'), "\n"; #...print to tty directly...
$telnet->print("bdf");
my ($output) = $telnet->waitfor('/[\$%#>] $/'); #...capture first...
print $output;
$telnet->close;
print "\n\n";
1;
...run as:
# ./mytelnet myserver mylogin
...with an appropriate '.netrc' file.
Regards!
...JRF...
I should add that using a '.netrc' file helps hide the password somewhat.
# cat ./mytelnet
#!/usr/bin/perl
use strict;
use warnings;
use Net::Netrc;
use Net::Telnet;
die "'host' 'login' expected\n" unless @ARGV == 2;
my ( $host, $login ) = ( shift, shift ) or die "Host User Pass expected\n";
my ( $machine, $pass, $acct );
if ( $machine = Net::Netrc->lookup( $host, $login ) ) {
( $login, $pass, $acct ) = $machine->lpa();
}
else {
die "No matching '.netrc' entry found\n";
}
my $telnet = new Net::Telnet;
$telnet->open($host);
$telnet->login( $login, $pass );
print $telnet->cmd('uname -a'), "\n"; #...print to tty directly...
$telnet->print("bdf");
my ($output) = $telnet->waitfor('/[\$%#>] $/'); #...capture first...
print $output;
$telnet->close;
print "\n\n";
1;
...run as:
# ./mytelnet myserver mylogin
...with an appropriate '.netrc' file.
Regards!
...JRF...
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP