0
我使用这个代码运行从C#程序中的Perl脚本来运行perl脚本:故障使用C#
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();
代码已基本从这里得到的 - https://social.msdn.microsoft.com/Forums/vstudio/en-US/ea9455e1-b254-49e1-99df-41718ea80b5b/how-to-run-perl-scripts-in-c
FILE_PATH一种说法到程序。 012irdir_path是程序应该查找它需要的数据的地方。 program.pl是我尝试使用的perl脚本。
通过命令行运行脚本没有问题。 使用我的代码运行时 - 它看起来好像perl脚本根本不运行(我不知道),如果它确实和失败我没有得到程序的输出。
它工作。简直不敢相信。谢谢! – proton
有一个随机upvote推动你超过1000 ;-) – CupawnTae
哈哈nice ty:D –