use strict; use warnings; use Expect; my $timeout = 5; my $password = "password"; my $shell_prompt = ']$ '; my $exp = new Expect; $exp->raw_pty(1); $exp= Expect->spawn("su") or die "Error calling su: $!\n"; unless ($exp->expect(5,"Password: ")) { die; # add error handling }; $exp->send("$password\n"); unless ($exp->expect(5, $shell_prompt)) { die; # add error handling }; print "Login successful\n";
In reply to Re^3: Responding to terminal I/O
by CountOrlok
in thread Responding to terminal I/O
by cspctec
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |