Click here to get back home

Expect.pm module help - simple question...

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Expect.pm module help - simple question... tudmuf2b 03-15-2005
Posted by tudmuf2b on March 15, 2005, 12:27 pm
Please log in for more thread options


I am playing around with the Expect module and have been looking at the
docs, but am confused as to why my code does not send the "ls" to the
remote host.

My code is below (along with the trace). The remote host does not have
NIS running so hence the warnings...

So I am trying to ssh to "moocow" and the just run and "ls" and get
that output but for whatever reason it just doesn't give me the ls
output. I do see that I get into expect part (where I am expecting to
get the $ prompt), but when I do a print "lsn", it doesn't work. I've
tried this with the $exp->send("lsr") but it doesn't work.

any ideas, as this is probably a simple issue???


#!/usr/local/bin/perl

use strict;
use warnings;
use Expect;

$Expect::Exp_Internal = 1;
#$Expect::Debug = 3;

my $exp = new Expect;

$exp->spawn("ssh moocow") || warn "Cannot spawn ssh: $!n";

if ( $exp->expect(12,"$ ") ) {
print "I made it in heren";
print $exp "lsn";
}
print "n";


=========================

Spawned 'ssh moocow'
spawn id(3)
Pid: 10919
Tty: /dev/pts/22
Expect::spawn('Expect=GLOB(0x9eb5f38)', 'ssh moocow') called at
../test
..expect.module.pl line 17
Starting EXPECT pattern matching...
Expect::expect('Expect=GLOB(0x9eb5f38)', 12, '$ ') called at
../test.ex
pect.module.pl line 19
spawn id(3): list of patterns:
#1: -ex `$ '


spawn id(3): Does `'
match:
pattern #1: -ex `$ '? No.

Waiting for new data (12 seconds)...
Warning: Remote host denied X11 forwarding, perhaps xauth program could
not be
run on the server side.

spawn id(3): Does `Warning: Remote host denied X11 forwarding, perhaps
xauth p
rogram could not be run on the server side.

rrn'
match:
pattern #1: -ex `$ '? No.

Waiting for new data (12 seconds)...
ypwhich: can't get local yp domain: Local domain name not set

spawn id(3): Does `Warning: Remote host denied X11 forwarding, perhaps
xauth p
rogram could not be run on the server side.rrnypwhich: can't get
local yp
domain: Local domain name not setrn'
match:
pattern #1: -ex `$ '? No.

Waiting for new data (12 seconds)...
moocow 1$
spawn id(3): Does `Warning: Remote host denied X11 forwarding, perhaps
xauth p
rogram could not be run on the server side.rrnypwhich: can't get
local yp
domain: Local domain name not setrnmoocow 1$ '
match:
pattern #1: -ex `$ '? YES!!
Before match string: `Warning: Remote host denied X11 forwarding,
perhaps
xauth program could not be run on the server side.rrnypwhich: can't
get lo
cal yp domain: Local domain name not setrnmoocow 1'
Match string: `$ '
After match string: `'
Matchlist: ()
Returning from expect successfully.
I made it in here



Similar ThreadsPosted
Expect::Simple December 1, 2005, 4:19 pm
Expect::Simple December 2, 2005, 9:22 am
Simple expect problem . March 21, 2007, 2:31 pm
Problem with very simple Expect script April 24, 2005, 8:42 pm
Perl Expect question November 8, 2004, 12:20 pm
Simple question September 15, 2005, 4:17 am
Killing all the child processes created through Expect module December 9, 2004, 4:58 am
DBI does not do what I expect... March 12, 2008, 4:18 am
using Net::SSH::Perl with Expect November 21, 2005, 3:41 pm
Expect: Getting PID at both ends of ssh January 22, 2007, 3:08 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap