sschneid has asked for the wisdom of the Perl Monks concerning the following question:
This works fine, it spits the password out to sudo, and sudo accepts it. The problem is, I then need to interact with the backup script (pre_backup.sh):my $exp = new Expect; $exp = Expect->spawn('sudo sh /usr/local/scripts/pre_backup.sh') or die "Cannot spawn pre-backup: $!\n\n"; if ($exp->expect(undef, 'Password')) { $exp->send("$password\cM"); }
...but Expect never sees the 'Press any key to continue' prompt from the pre_backup script, it is still looking for text from the sudo pty, not the second pty which sudo itself spawns.if ($exp->expect(undef, 'any key to continue')) { $exp->send("\cM"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Expect.pm and sudo.
by robartes (Priest) on Oct 16, 2002 at 20:05 UTC | |
by sschneid (Deacon) on Oct 16, 2002 at 20:49 UTC | |
by Aristotle (Chancellor) on Oct 17, 2002 at 01:59 UTC |