----- Original Message ----- 
From: "Mumia W." <[EMAIL PROTECTED]>
To: "Beginners List" <beginners@perl.org>
Sent: Thursday, August 31, 2006 11:29 AM
Subject: [Bulk] Re: Totally lost - need a starting point


> On 08/31/2006 08:24 AM, Helen wrote:
> > ----- Original Message -----
> > From: "Charles K. Clarkson" <[EMAIL PROTECTED]>
> > To: <beginners@perl.org>
> > Sent: Wednesday, August 30, 2006 10:16 PM
> > Subject: [Bulk] RE: Totally lost - need a starting point
> >
> >
> >> Helen wrote:
> >>
> >>> I am starting from scratch again reading the manual more
> >>> completely. I am just running out of time on my deadline.
> >>
> >>     Break down your task into small pieces and solve for
> >> those pieces. The first piece I can see is running an Expect
> >> script from a perl program. Do you know how to do that?
> >>
> >>     I have no idea what Expect is, but searching for
> >> 'expect' and 'perl' in Google revealed a perl module for
> >> expect.
> >>
> >>     The other pieces of your problem might include getting
> >> form values from an HTML form. CGI.pm can help with that.
> >>
> >>
> >> HTH,
> >>
> >> Charles K. Clarkson
> >
> > Yes I have a perl script running inside of the expect script, which
works
> > fine.  I need to find a way to call the expect script and output the
perl
>
> What perl?
>
>
> > to the html page that is calling it.  I found a version of expect for
perl, but
> > it didn't seem to be able to get the results that I was looking for,
being
> > able to telnet into a terminal and offer up passwords and such. then run
> > another perl script that was picked as an option.
> >
> > Helen
> >
>
> Hello Helen. First, you're confusing me; please don't
> top-post, and "[Bulk] RE:" should not have been added to the
> subject line; tame your mail-reader.
>
> Second, Expect.pm can do telnet:
>
> use strict;
> use warnings;
> use Expect;
>
>
> my $exp = Expect->spawn(telnet => qw(localhost 80))
>      or die ("Spawn failed: $!\n");
>
> my $data = '';
> my $tosend = q{GET / HTTP/1.1
> Host: localhost
> Connection: close
>
> };
>
> $exp->expect(4,
>      [ '^Escape char' => sub {
>          $exp->send($tosend);
>      }],
> );
>
> $exp->expect(4,
>      [ '^HTTP/1.1' => sub {
>          $data = $exp->match . $exp->after;
>      }],
> );
>
> $exp->soft_close;
> print "----------------------------------\n";
> print $data;
>
> __END__
>
> On my system, the output from my local web-server appears.
>
> HTH
>
>
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
Thanks for the information and the routine for this group.

I have written the expect scripts, which telnet into a terminal and then run
scripts writen by the OEM. The scripts test the condition of the
communication terminal. From all the researching that I have done in the
past weeks, many people have asked this same question and the answer is
never shown.  I have been reading the tutorials and I am still not capable.

Helen

working example of an expect script called  telenet_term_tu_status.exp

#! /usr/bin/expect
set terminal1 "192.168.128.100"

set username "username"

set passwd "password"

spawn telnet "$terminal1"

expect "Username: "

send "$username\r"

expect "Password: "

send "$passwd\r"

expect "MSV-> "

send "tu_status\r"

expect "MSV-> "

send "exit\r"

interact


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to