# Read the signing image_type from the client app via the socket $image_type = <$client_socket>; chop($image_type); # Setup some default filenames and command strings. my $unsigned_file = "unsigned.bin"; my $signed_filename; my $output_file = "signed.$unsigned_file"; my $rcv_filesize; my $hsm_cmd; my $buf; my $error = "ACK\n"; $rcv_filesize = 0; my $i = 1; while (-e $output_file) { $output_file = "output.$input_file$i"; $i++; } $abc_cmd = "abc.exe" -i $input_file -o $output_file"; print $client_socket "ACK\n"; system $abc_cmd; # Run the command print "DONE\n"; # Open the file for reading open(INFILE, $output_file) || die "ERROR: Could not open output_file for reading!\n"; binmode INFILE; { local $/; $output_data = ; } close(INFILE); print "$prefix Sending $output_file to the client... "; $client_socket->write($output_data, length($output_data)); print length($output_data), " bytes: DONE\n"; $client_socket->close(); print "$prefix Socket closed, operation completed!\n";