Phoenix.pm: Expect.pm question
Douglas E. Miles
doug.miles at bpxinternet.com
Fri Nov 5 16:21:23 CST 1999
I'm having trouble getting Expect.pm to work with passwd. Basically,
the patterns all appear to match, but it hangs at the end. Here's the
code snippet:
##################################################
$Expect::Debug = 3;
my $passwd = Expect->spawn('/usr/bin/passwd');
$passwd->expect(undef, '(current) UNIX password:');
print "$current_password\n";
print $passwd "$current_password\n";
$passwd->expect(undef, 'New UNIX password:');
print "$new_password\n";
print $passwd "$new_password\n";
$passwd->expect(undef, 'Retype new UNIX password:');
print "$new_password\n";
print $passwd "$new_password\n";
$passwd->soft_close;
##################################################
Here's the output:
##################################################
Spawned '/usr/bin/passwd' (spawn id(4))
Pid: 924
Tty: /dev/ttya0
Beginning expect from spawn id(4).
Accumulator: ''
Expect timeout time: unlimited seconds.
expect: Pty=spawn id(4), time=941839574, loop_time=undef
expect: handle spawn id(4) ready.
expect: read 54 byte(s) from spawn id(4).
Changing password for user2
(current) UNIX password: Matched pattern 1 ('(current) UNIX password:')!
Before match string: 'Changing password for user2\r\n'
Match string: '(current) UNIX password:'
After match string: ' '
Returning from expect successfully.
Accumulator: ' '
password
Beginning expect from spawn id(4).
Accumulator: ' '
Expect timeout time: unlimited seconds.
expect: Pty=spawn id(4), time=941839574, loop_time=undef
expect: handle spawn id(4) ready.
expect: read 2 byte(s) from spawn id(4).
expect: handle spawn id(4) ready.
expect: read 19 byte(s) from spawn id(4).
New UNIX password: Matched pattern 1 ('New UNIX password:')!
Before match string: ' \r\n'
Match string: 'New UNIX password:'
After match string: ' '
Returning from expect successfully.
Accumulator: ' '
N8ZRccmS
Beginning expect from spawn id(4).
Accumulator: ' '
Expect timeout time: unlimited seconds.
expect: Pty=spawn id(4), time=941839574, loop_time=undef
expect: handle spawn id(4) ready.
expect: read 2 byte(s) from spawn id(4).
expect: handle spawn id(4) ready.
expect: read 26 byte(s) from spawn id(4).
Retype new UNIX password: Matched pattern 1 ('Retype new UNIX
password:')!
Before match string: ' \r\n'
Match string: 'Retype new UNIX password:'
After match string: ' '
Returning from expect successfully.
Accumulator: ' '
N8ZRccmS
Beginning expect from spawn id(4).
Accumulator: ' '
Expect timeout time: unlimited seconds.
expect: Pty=spawn id(4), time=941839574, loop_time=undef
expect: handle spawn id(4) ready.
expect: read 10 byte(s) from spawn id(4).
N8ZRccmS
##################################################
Any help for this expect impaired hacker is appreciated. :)
--
For a list of the ways which technology has failed
to improve our quality of life, press 3.
More information about the Phoenix-pm
mailing list