#!/usr/local/bin/perl # # Program: start-apache-ssl.pl # Description: Start Apache SSL with PEM pass phrase enabled. # Version: 1.3 # Last Update: 14 October 2002 # Written by: Dusan U. Baljevic # # Copyright 2006-2014 Dusan Baljevic # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # Requirements: Perl # Expect-1.15 or better # IO-Tty-1.02 or better # # Make the script very tight. # $ENV{'PATH'} = '/bin:/usr/bin:/usr/local/sbin'; $ENV{'SHELL'} = '/bin/sh' if $ENV{'SHELL'} ne ''; $ENV{'IFS'} = '' if $ENV{'IFS'} ne ''; require 5.004; use strict; use Expect; use vars qw($Command $sh $PEM_Prompt $PEM_Pass); $| = 1; $Expect::Log_Stdout = 0; # First we have to initialize STDIN in to an expect object. my $stdin = Expect->exp_init( \*STDIN ); my $stdout = Expect->exp_init( \*STDOUT ); my $PEM_Prompt = "Enter PEM pass phrase"; my $PEM_Pass = "what#ever-PEM-password"; $Command = "/usr/local/apache-ssl/bin/httpsdctl start"; $sh = Expect->spawn("$Command") or die "ERROR: Spawn failed: $?"; print "NOTE: Executing $Command...\n"; $sh->log_stdout(0); # Log to STDOUT unless ( $sh->expect( 5, '-re', "$PEM_Prompt:" ) ) { print "ERROR: Timeout executing the $Command.\n"; } print "NOTE: Passing the PEM pass phrase...\n"; print $sh "$PEM_Pass\r"; exit(0);