I'm on a Solaris box running Perl 5.6.1, I can't upgrade it and I can only use pure perl modules since our Unix admins in their infinite wisdom decided not to install a C compiler. And this is the government so forget about asking for any changes.
Which is why I'm using Comm.pl instead of Expect.pm or something more modern.
I modified an example from the bottom of Comm.pl.
Update:
Sorry I removed some extraneous code before posting but after executing. The output now reflects the code as shown.
Here's the code with the problem:
use strict;
use warnings;
$| = 1;
require 'Comm.pl';
use IPC::Open3 qw/open3/;
&Comm::init(1.8);
my $TimeOut = 30;
my $Server = 'Server';
my $User = 'User';
my $Password = 'Password';
my ( $Proc_pty_handle, $Proc_tty_handle, $pid ) = &open_proc( "bteq");
die "open_proc failed" unless $Proc_pty_handle;
my ($success, $matched, $before_match, $after_match) = &expect($Proc_p
+ty_handle, $TimeOut, 'Enter your logon or BTEQ command:');
die("Time out\n") unless ($success);
print("
\$matched \[$matched\]
\$before_match\[$before_match\]
\$success \[$success\]
\$after_match \[$after_match \]
");
print $Proc_pty_handle ".logon $Server/$User\n";
Here's the output:
$matched []
$before_match[
Teradata BTEQ 08.02.04.00 for UNIX5.
Copyright 1984-2006, NCR Corporation. ALL RIGHTS RESERVED.
]
$success [Enter your logon or BTEQ command:]
$after_match [
]
Can't use string ("proccommutils000001") as a symbol ref while "strict
+ refs" in use at btp.pl line 25.
I've not a clue what is going on here. This is my first attempt at any kind of an expect type app which might be part of the problem.
Thanks.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.