proton
proton

Reputation: 431

failure to run a perl script using C#

I am using this code to run a perl script from a C# program:

        String config_location = file_path
        ProcessStartInfo perlStartInfo = new ProcessStartInfo(@"C:\Perl64\bin\perl.exe");


        perlStartInfo.Domain="C:\\e\\oa\\dir_path";
        perlStartInfo.FileName = "C:\\Perl64\\bin\\perl.exe";
        perlStartInfo.Arguments = "C:\\e\\oa\\Evergreen\\evg\\scripts\\helper\\program.pl" + "-config" + config_location;
        perlStartInfo.UseShellExecute = false;
        perlStartInfo.RedirectStandardOutput = false;
        perlStartInfo.RedirectStandardError = false;
        perlStartInfo.RedirectStandardInput = false;
        perlStartInfo.CreateNoWindow = false;
        perlStartInfo.WorkingDirectory="C:\\e\\oa\\dir_path";

        Process perl = new Process(); 
        perl.StartInfo = perlStartInfo;
        perl.Start();
        perl.WaitForExit();

the code was basically obtained from here - https://social.msdn.microsoft.com/Forums/vstudio/en-US/ea9455e1-b254-49e1-99df-41718ea80b5b/how-to-run-perl-scripts-in-c

file_path is an argument to the program. dir_path is where the program should look for the data it requires. program.pl is the perl script I am trying to use.

running the script through the command line goes without problems. when runing using my code - it seems as though the perl script doesn't run at all (i'm not sure), and if it does and fail i'm not getting the program's output.

Upvotes: 0

Views: 329

Answers (1)

Alexis Peters
Alexis Peters

Reputation: 1631

maybe you've missed the whitespaces in Arguments ?

perlStartInfo.Arguments = "C:\\e\\oa\\Evergreen\\evg\\scripts\\helper\\program.pl -config " + config_location;

Upvotes: 4

Related Questions