#!/usr/bin/perl
require  'config/paths.pl';
my $target = "$ARGV[0]";
my $cmd    = "$ARGV[1]";
my $port   = 443;
my $args   = "s_client -quiet -connect $target:$port";
$cmd =~ s/\\n/\n/g;
$cmd =~ s/\\r/\r/g;

die "Usage bin/https <target> <command>\n" if(!$cmd);
if ($OPENSSL) {
    eval {
    open (SSL, "$OPENSSL $args 2>/dev/null<<EOC
$cmd 
EOC |");
        while (<SSL>) {
          $_ =~ s/\n/\\n/g;
          $_ =~ s/\r/\\r/g;
          print;
        }
        close SSL;
        alarm 0;
   }
}
