- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Perl telnet VMS problem
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
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
Community
Resources
Forums
Blogs
- 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
тАО08-03-2010 06:39 AM
тАО08-03-2010 06:39 AM
I want to telnet OpenVMS system by Perl and run a command. I can log in success but cannot identify the input. Below is my script:
use Net::Telnet();
use Test::Harness::Straps;
my ($hostname, $username, $password, $t,@lines);
$username="name";
$password="password";
$hostname= "a.b.c.d";
my $strap = Test::Harness::Straps->new();
$t = new Net::Telnet (Timeout=>20);
$t->open (Host =>$hostname);
$t->waitfor(-match=> '/Username: ?$/i',
-errmode =>"return") or die "Username problem connecting to host:", $t->lastline;
$t->print ($username);
$t->waitfor(-match=> '/Password: ?$/i',
-errmode =>"return") or die "Password problem connecting to host:", $t->lastline;
$t->print ($password);
sleep (5);
$t->waitfor(-match=> '^hostname\s.*> ?$/i',
-errmode =>"return") or die "Wait time is not enought long:", $t->lastline;
$t->print("copy xlbyperl.txt xlbyperl1.txt");
And the run result is: Wait time is not enought long:", "name".
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-03-2010 07:00 AM
тАО08-03-2010 07:00 AM
Re: Perl telnet VMS problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-03-2010 07:13 AM
тАО08-03-2010 07:13 AM
Re: Perl telnet VMS problem
Here is what I asked in return, but I haven;t seen answers...
Just casually reading is seems to me that it is waiting for a very specific prompt:
"^hostname\s.*>"
So that is a word 'host' at the begin of a line followed by any, or no, white-space, and a '>' character.
When you log in manually, is that what you see?
What do you see as prompt? Just a "$ " perhaps?
Does the word 'hostname' have to be edited to match reality?
Does it need to be a variable ($hostname), or something like '\w+' to match any word?
Finally where is that perl running?
On the OpenVMS box itself?
Did you try from windows/linux?
Regards,
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-03-2010 06:16 PM
тАО08-03-2010 06:16 PM
Re: Perl telnet VMS problem
(Of course, it may be that the trailing '?' is required by the waitfor() method, but I'd be surprised if that was the case.)
Regards,
Jeremy Begg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-03-2010 07:30 PM
тАО08-03-2010 07:30 PM
Re: Perl telnet VMS problem
>Username prompt. It looks to me like it's waiting for
>"Username: ?" i.e. with a trailing '?'. But when VMS prompts
>the user at login there's no '?', hence the Perl script stalls.
The match in the waitfor method is done on a regular expression and the question mark means the preceding character (or character class, or grouping) is optional. If it died waiting for username I think it would die with the username error, not the prompt error.
The docs for the module (including how to turn on debugging options) are here:
http://search.cpan.org/~jrogers/Net-Telnet-3.03/lib/Net/Telnet.pm
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-03-2010 08:53 PM
тАО08-03-2010 08:53 PM
Re: Perl telnet VMS problem
I tried to make the prompt simple and tried again. It still does not work. And the problem is: My script can only see the line before last line(the last line is what I want to input my command in). It cannot see the last line. And does anyone was experienced in telnet openvms? Could you post your success script for me? Appreciate it very much!
sanshi leilei
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-04-2010 04:17 AM
тАО08-04-2010 04:17 AM
Re: Perl telnet VMS problem
Think about it for a moment, what would we need to know?
1) What does a normal telnet sequence look like on the target box? Just execute one manually all the way including the first shell line (DCL prompt)
For example, does it look like:
N O T I C E
Access is for subscribed individuals only.
Username: hein
Password:
Welcome to OpenVMS (TM) Alpha Operating System, Version V8.3 on node EISNER
Last interactive login on Monday, 2-AUG-2010 05:58:43.15
Last non-interactive login on Wednesday, 28-JUL-2010 09:13:02.07
1 failure since last successful login
$
2) Which 'die' command is executed? Username, Password, or 'Wait time'? I believe the latter.
3) Is there an error being returned? print $t->errmsg ?
Did you google and read? My first hits:
-- http://www.foo.be/docs/tpj/issues/vol2_4/tpj0204-0009.html
-- http://search.cpan.org/~jrogers/Net-Telnet-3.03/lib/Net/Telnet.pm
Why the "?" in the username and password match strings? It shouldn't hurt, but still. You should know what to expect.
Good luck!
Hein
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-04-2010 05:01 PM
тАО08-04-2010 05:01 PM
Solution1.) As I mentioned earlier, the documentation clearly describes how to turn on debugging by adding the "Dump_log" parameter when calling the "new" method. There is absolutely no excuse for guessing (or leaving potential respondents to guess) how far it got before failing.
2.) Reporting the value of the "lastline" method on error is really not much help. That will show you the last thing successfully sent and nothing at all about what went wrong. Using the "errmsg" method does work if what you want it is the error message.
3.) The "sleep (5);" line just makes the client stall while the server is trying to write data to it. Deleting it and letting the waitfor method do what its name implies works better.
4.) The prompt that it's expecting is definitely not the default, and while possible, is not like anything I've seen on a VMS system. If the following command were in sys$manager:sylogin.com or the login.com of the user running this, it would create such a prompt:
$ set prompt="hostname ''f$getsyi(""NODENAME"")'> "
but I can't think of a reason to change the prompt -- just make the script able to catch whatever prompt(s) it will be run against.
I've attached a script that corrects the problems above. It sends the SHOW TIME command to the host and looks like so when run on my system with the default dollar sign prompt:
% perl nettelnet.pl
4-AUG-2010 19:19:49
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-04-2010 07:18 PM
тАО08-04-2010 07:18 PM
Re: Perl telnet VMS problem
use strict;
use Net::Telnet();
my $username = shift @ARGV;
my $password = shift @ARGV;
my $hostname = shift @ARGV;
my $t = new Net::Telnet(Timeout=>20,
Dump_log => 'nettelnet.log');
$t->open(Host => $hostname);
$t->waitfor(-match => '/Username: ?$/i',
Errmode => 'return')
or die "Username problem connecting to host:", $t->errmsg;
$t->print ($username);
$t->waitfor(-match => '/Password: ?$/i',
Errmode => 'return')
or die "Password problem connecting to host:", $t->errmsg;
$t->print ($password);
$t->waitfor(-match => '/[\$%#>] $/',
Errmode => 'return')
or die "Timeout waiting for prompt:", $t->errmsg;
print $t->cmd("show time");