I am trying to capture the certificate information of a particular site and send it to a file in windows using perl. To achieve this, I wrote the below code in certextract.pl:
$commandToExecute = "openssl s_client -connect varcert.test.com:8334";
my $filename = 'C:\F6\certoutput.txt';
my @cmdout = `$commandToExecute`;
open(my $cmd, '>', $filename) or die "Could not open file '$filename' $!";
print $cmd @cmdout;
But when I execute perl certextract.pl, this doesn't write the output to a file unless I hit enter as openssl command itself is not exiting unless I hit enter. i.e., the command openssl s_client -connect varcert.test.com:8334 doesn't exit unless I hit enter in the command prompt. Hence perl also is not exiting. As I am using this perl file in automation, I want the output to be written without manual intervention. Can someone please help me with this?
@cmdoutto a scalar instead,$cmdout. That should concatenate the lines of your output instead. Your problem sounds like a terminal issue. Are you sure nothing is written to the file?perl certextract.plin cmd window?