<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Perl telnet VMS problem in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/perl-telnet-vms-problem/m-p/4669696#M40316</link>
    <description>It doesn't look as though your problem is with either Perl or telnet.  Most likely it's because this particular script is expecting the command prompt to match the pattern '^hostname\s.*&amp;gt; ?$/i' and chances are your system's command prompt doesn't match that pattern.  Change your command prompt or change your program to look for the prompt you actually have.  (Perhaps you meant to use the variable $hostname and not the string 'hostname'?)</description>
    <pubDate>Tue, 03 Aug 2010 14:00:14 GMT</pubDate>
    <dc:creator>Craig A Berry</dc:creator>
    <dc:date>2010-08-03T14:00:14Z</dc:date>
    <item>
      <title>Perl telnet VMS problem</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/perl-telnet-vms-problem/m-p/4669695#M40315</link>
      <description>Morning.&lt;BR /&gt;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:&lt;BR /&gt; &lt;BR /&gt;use Net::Telnet();&lt;BR /&gt;use Test::Harness::Straps;&lt;BR /&gt;my ($hostname, $username, $password, $t,@lines);&lt;BR /&gt;$username="name";&lt;BR /&gt;$password="password";&lt;BR /&gt;$hostname= "a.b.c.d";&lt;BR /&gt;my $strap = Test::Harness::Straps-&amp;gt;new();&lt;BR /&gt;$t = new Net::Telnet (Timeout=&amp;gt;20);&lt;BR /&gt;$t-&amp;gt;open (Host =&amp;gt;$hostname);&lt;BR /&gt;$t-&amp;gt;waitfor(-match=&amp;gt; '/Username: ?$/i', &lt;BR /&gt;      -errmode =&amp;gt;"return") or die "Username problem connecting to host:", $t-&amp;gt;lastline;&lt;BR /&gt;$t-&amp;gt;print ($username);         &lt;BR /&gt;$t-&amp;gt;waitfor(-match=&amp;gt; '/Password: ?$/i',                                                &lt;BR /&gt;      -errmode =&amp;gt;"return") or die "Password problem connecting to host:", $t-&amp;gt;lastline;&lt;BR /&gt;$t-&amp;gt;print ($password);&lt;BR /&gt;sleep (5);&lt;BR /&gt;$t-&amp;gt;waitfor(-match=&amp;gt; '^hostname\s.*&amp;gt; ?$/i',                                                      &lt;BR /&gt;      -errmode =&amp;gt;"return") or die "Wait time is not enought long:", $t-&amp;gt;lastline;&lt;BR /&gt;$t-&amp;gt;print("copy xlbyperl.txt xlbyperl1.txt");&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;And the run result is: Wait time is not enought long:", "name".</description>
      <pubDate>Tue, 03 Aug 2010 13:39:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/perl-telnet-vms-problem/m-p/4669695#M40315</guid>
      <dc:creator>sanshi_leilei</dc:creator>
      <dc:date>2010-08-03T13:39:37Z</dc:date>
    </item>
    <item>
      <title>Re: Perl telnet VMS problem</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/perl-telnet-vms-problem/m-p/4669696#M40316</link>
      <description>It doesn't look as though your problem is with either Perl or telnet.  Most likely it's because this particular script is expecting the command prompt to match the pattern '^hostname\s.*&amp;gt; ?$/i' and chances are your system's command prompt doesn't match that pattern.  Change your command prompt or change your program to look for the prompt you actually have.  (Perhaps you meant to use the variable $hostname and not the string 'hostname'?)</description>
      <pubDate>Tue, 03 Aug 2010 14:00:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/perl-telnet-vms-problem/m-p/4669696#M40316</guid>
      <dc:creator>Craig A Berry</dc:creator>
      <dc:date>2010-08-03T14:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: Perl telnet VMS problem</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/perl-telnet-vms-problem/m-p/4669697#M40317</link>
      <description>Sanshi had send this question to me by Email a while back.&lt;BR /&gt;&lt;BR /&gt;Here is what I asked in return, but I haven;t seen answers...&lt;BR /&gt;&lt;BR /&gt;Just casually reading is seems to me that it is waiting for a very specific prompt:&lt;BR /&gt;"^hostname\s.*&amp;gt;"&lt;BR /&gt;So that is a word 'host' at the begin of a line followed by any, or no, white-space, and a '&amp;gt;' character.&lt;BR /&gt;When you log in manually, is that what you see?&lt;BR /&gt;What do you see as prompt? Just a "$ " perhaps?&lt;BR /&gt;Does the word 'hostname' have to be edited to match reality?&lt;BR /&gt;Does it need to be a variable ($hostname), or something like '\w+' to match any word?&lt;BR /&gt;&lt;BR /&gt;Finally where is that perl running? &lt;BR /&gt;On the OpenVMS box itself? &lt;BR /&gt;Did you try from windows/linux?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Hein&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Aug 2010 14:13:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/perl-telnet-vms-problem/m-p/4669697#M40317</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2010-08-03T14:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: Perl telnet VMS problem</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/perl-telnet-vms-problem/m-p/4669698#M40318</link>
      <description>The result being seen is that it's waiting on "name" i.e. the 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.&lt;BR /&gt;&lt;BR /&gt;(Of course, it may be that the trailing '?' is required by the waitfor() method, but I'd be surprised if that was the case.)&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Jeremy Begg</description>
      <pubDate>Wed, 04 Aug 2010 01:16:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/perl-telnet-vms-problem/m-p/4669698#M40318</guid>
      <dc:creator>Jeremy Begg</dc:creator>
      <dc:date>2010-08-04T01:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: Perl telnet VMS problem</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/perl-telnet-vms-problem/m-p/4669699#M40319</link>
      <description>&amp;gt;The result being seen is that it's waiting on "name" i.e. the&lt;BR /&gt; &amp;gt;Username prompt. It looks to me like it's waiting for &lt;BR /&gt;&amp;gt;"Username: ?" i.e. with a trailing '?'. But when VMS prompts &lt;BR /&gt;&amp;gt;the user at login there's no '?', hence the Perl script stalls.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;The docs for the module (including how to turn on debugging options) are here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://search.cpan.org/~jrogers/Net-Telnet-3.03/lib/Net/Telnet.pm" target="_blank"&gt;http://search.cpan.org/~jrogers/Net-Telnet-3.03/lib/Net/Telnet.pm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 04 Aug 2010 02:30:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/perl-telnet-vms-problem/m-p/4669699#M40319</guid>
      <dc:creator>Craig A Berry</dc:creator>
      <dc:date>2010-08-04T02:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: Perl telnet VMS problem</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/perl-telnet-vms-problem/m-p/4669700#M40320</link>
      <description>Thank you all so much. I'm trying the script on windows to remote access OPENVMS.&lt;BR /&gt;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!&lt;BR /&gt;&lt;BR /&gt;sanshi leilei</description>
      <pubDate>Wed, 04 Aug 2010 03:53:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/perl-telnet-vms-problem/m-p/4669700#M40320</guid>
      <dc:creator>sanshi_leilei</dc:creator>
      <dc:date>2010-08-04T03:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: Perl telnet VMS problem</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/perl-telnet-vms-problem/m-p/4669701#M40321</link>
      <description>&lt;!--!*#--&gt;Sanshi my friend, you are NOT helping.&lt;BR /&gt;Think about it for a moment, what would we need to know?&lt;BR /&gt;&lt;BR /&gt;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)&lt;BR /&gt;For example, does it look like:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;                                N O T I C E&lt;BR /&gt;&lt;BR /&gt;Access is for subscribed individuals only.&lt;BR /&gt;Username: hein&lt;BR /&gt;Password:&lt;BR /&gt;   Welcome to OpenVMS (TM) Alpha Operating System, Version V8.3 on node EISNER&lt;BR /&gt;    Last interactive login on Monday,  2-AUG-2010 05:58:43.15&lt;BR /&gt;    Last non-interactive login on Wednesday, 28-JUL-2010 09:13:02.07&lt;BR /&gt;        1 failure since last successful login&lt;BR /&gt;&lt;BR /&gt;$ &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;2) Which 'die' command is executed? Username, Password, or 'Wait time'? I believe the latter.&lt;BR /&gt;&lt;BR /&gt;3) Is there an error being returned? print $t-&amp;gt;errmsg ?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Did you google and read? My first hits:&lt;BR /&gt;&lt;BR /&gt;-- &lt;A href="http://www.foo.be/docs/tpj/issues/vol2_4/tpj0204-0009.html" target="_blank"&gt;http://www.foo.be/docs/tpj/issues/vol2_4/tpj0204-0009.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;-- &lt;A href="http://search.cpan.org/~jrogers/Net-Telnet-3.03/lib/Net/Telnet.pm" target="_blank"&gt;http://search.cpan.org/~jrogers/Net-Telnet-3.03/lib/Net/Telnet.pm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Why the "?" in the username and password match strings? It shouldn't hurt, but still. You should know what to expect.&lt;BR /&gt;&lt;BR /&gt;Good luck!&lt;BR /&gt;Hein</description>
      <pubDate>Wed, 04 Aug 2010 11:17:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/perl-telnet-vms-problem/m-p/4669701#M40321</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2010-08-04T11:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: Perl telnet VMS problem</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/perl-telnet-vms-problem/m-p/4669702#M40322</link>
      <description>There were several easily fixable problems in the original script.  Hein mentioned some of these, and since most of his advice seems to have been ignored, I expect mine will be too, but here goes:&lt;BR /&gt;&lt;BR /&gt;1.) 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.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;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:&lt;BR /&gt;&lt;BR /&gt;$ set prompt="hostname ''f$getsyi(""NODENAME"")'&amp;gt; "&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;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:&lt;BR /&gt;&lt;BR /&gt;% perl nettelnet.pl &lt;USERNAME&gt; &lt;PASSWORD&gt; myhost.mydomain.com&lt;BR /&gt;   4-AUG-2010 19:19:49&lt;/PASSWORD&gt;&lt;/USERNAME&gt;</description>
      <pubDate>Thu, 05 Aug 2010 00:01:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/perl-telnet-vms-problem/m-p/4669702#M40322</guid>
      <dc:creator>Craig A Berry</dc:creator>
      <dc:date>2010-08-05T00:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: Perl telnet VMS problem</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/perl-telnet-vms-problem/m-p/4669703#M40323</link>
      <description>&lt;!--!*#--&gt;Hmm.  Trying the attachment again.  Also inline in case it fails again:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use Net::Telnet();&lt;BR /&gt;&lt;BR /&gt;my $username = shift @ARGV;&lt;BR /&gt;my $password = shift @ARGV;&lt;BR /&gt;my $hostname = shift @ARGV;&lt;BR /&gt;&lt;BR /&gt;my $t = new Net::Telnet(Timeout=&amp;gt;20, &lt;BR /&gt;                        Dump_log =&amp;gt; 'nettelnet.log');&lt;BR /&gt;$t-&amp;gt;open(Host =&amp;gt; $hostname);&lt;BR /&gt;&lt;BR /&gt;$t-&amp;gt;waitfor(-match =&amp;gt; '/Username: ?$/i',&lt;BR /&gt;            Errmode =&amp;gt; 'return') &lt;BR /&gt;    or die "Username problem connecting to host:", $t-&amp;gt;errmsg;&lt;BR /&gt;$t-&amp;gt;print ($username); &lt;BR /&gt;&lt;BR /&gt;$t-&amp;gt;waitfor(-match =&amp;gt; '/Password: ?$/i',&lt;BR /&gt;            Errmode =&amp;gt; 'return') &lt;BR /&gt;    or die "Password problem connecting to host:", $t-&amp;gt;errmsg;&lt;BR /&gt;$t-&amp;gt;print ($password);&lt;BR /&gt;&lt;BR /&gt;$t-&amp;gt;waitfor(-match =&amp;gt; '/[\$%#&amp;gt;] $/',&lt;BR /&gt;            Errmode =&amp;gt; 'return') &lt;BR /&gt;     or die "Timeout waiting for prompt:", $t-&amp;gt;errmsg;&lt;BR /&gt;&lt;BR /&gt;print $t-&amp;gt;cmd("show time");&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Aug 2010 02:18:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/perl-telnet-vms-problem/m-p/4669703#M40323</guid>
      <dc:creator>Craig A Berry</dc:creator>
      <dc:date>2010-08-05T02:18:17Z</dc:date>
    </item>
  </channel>
</rss>

