#!/usr/bin/perl use Expect; my $apache = "/usr/local/apache-ssl/bin/apachectl"; $command = Expect->spawn($apache, 'startssl') or die "Couldn't start program: $!\n"; # prevent the program's output from being shown on STDOUT # $command->log_stdout(0); # wait 10 seconds for pass phrase unless ($command->expect(20, -re => "Enter pass phrase ?")) { # timed out } # send passphrase print $command "NotARealPassPhrase\r"; ## wait 10 seconds for confirmation of server start. unless ($command->expect(10, -re => "Ok: Pass Phrase Dialog successful.")) { die "Passphrase excepted!\n"; } ## wait 10 seconds for confirmation of server start. Otherwise, die unless ($command->expect(10, -re => "startssl: httpd started")) { die "SSL Didn't start!\n"; } # program will terminate by itself, finish with $command->soft_close();