Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Expect module - need some help...

Reply
Thread Tools

Expect module - need some help...

 
 
tudmuf2b@onebox.com
Guest
Posts: n/a
 
      03-16-2005

Hey folks...

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 "ls\n", it doesn't work. I've
tried this with the $exp->send("ls\r") 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:ebug = 3;

my $exp = new Expect;

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

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

print "\n";

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

Spawned 'ssh moocow'
spawn id(3)
Pid: 10919
Tty: /dev/pts/22
Expect::spawn('Expect=GLOB(0x9eb5f3', 'ssh moocow') called at
../test
..expect.module.pl line 17
Starting EXPECT pattern matching...
Expect::expect('Expect=GLOB(0x9eb5f3', 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.\

r\r\n'
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.\r\r\nypwhich: can\'t get
local yp
domain: Local domain name not set\r\n'
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.\r\r\nypwhich: can\'t get
local yp
domain: Local domain name not set\r\nmoocow 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.\r\r\nypwhich: can\'t
get lo
cal yp domain: Local domain name not set\r\nmoocow 1'
Match string: `$ '
After match string: `'
Matchlist: ()
Returning from expect successfully.
I made it in here

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Expect.pm like module in ruby Praveen Ray Ruby 1 05-06-2008 06:02 PM
how to expect eof with expect+pty Simon Strandgaard Ruby 4 12-20-2006 04:00 PM
Bug in $obj->expect() ... ? (Expect 1.15) Phil Perl Misc 0 07-07-2006 07:25 AM
Re: module docstring, documentation,anything? please note is the module type/object NOT some module Maric Michaud Python 0 06-24-2006 12:42 PM
EXPECT module, howto to perform a "new page" ? z0mb1e_fr Perl 2 12-03-2003 10:58 AM



Advertisments