this is my c# code and perl code. to simplify, it just passes two variable and print to txt file.
namespace testperl
{
class Program
{
static void Main(string[] args)
{
string fullPath = @"C:\Perl64\bin\perl.exe";
string arguments = @"C:\Users\Desktop\old.pl"+"aa" + "bb";
Process myProcess = Process.Start(fullPath, arguments);
myProcess.WaitForExit(999);
if (!myProcess.HasExited)
{
myProcess.Kill();
throw new Exception("Timed out while running process");
}
Console.WriteLine("all set");
Console.ReadKey();
}
}
the perl code:
use strict;
use warnings;
use Carp;
use English qw(-no_match_vars);
my $files = 'report.txt';
if (-f $files) {
unlink $files
or croak "Cannot delete $files: $!";
}
my $OUTFILE;
my ($name, $number) = @ARGV;
if (not defined $name) {
die "Need name\n";
}
open $OUTFILE, '>>', $files
or croak "Cannot open $files: $OS_ERROR";
if (defined $number) {
print { $OUTFILE } "thing, $name \n"
or croak "Cannot write to $files: $OS_ERROR";
}
close $OUTFILE
or croak "Cannot close $files: $OS_ERROR";