Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 为什么可以';使用ASP.NET调用Perl脚本';系统诊断程序?_C#_.net_Asp.net_Perl - Fatal编程技术网

C# 为什么可以';使用ASP.NET调用Perl脚本';系统诊断程序?

C# 为什么可以';使用ASP.NET调用Perl脚本';系统诊断程序?,c#,.net,asp.net,perl,C#,.net,Asp.net,Perl,我试图使用System.Diagnostics.Process类从ASP.NET应用程序中运行Perl脚本。当我在命令行中键入Perl命令时,该命令运行良好,但当ASP.NET尝试运行同一命令时,该命令不起作用 我怀疑这可能与输入和输出流有关。Perl脚本在命令行上运行到完成需要很长时间。但是在.NET中,命令几乎立即返回,当我尝试重定向Perl脚本的标准输出以查看生成了什么消息时,它只显示第一行并返回。使用阻塞流读取技术无法解决此问题。NET确实认为Perl脚本只输出一行,然后就完成了 有什么

我试图使用
System.Diagnostics.Process
类从ASP.NET应用程序中运行Perl脚本。当我在命令行中键入Perl命令时,该命令运行良好,但当ASP.NET尝试运行同一命令时,该命令不起作用

我怀疑这可能与输入和输出流有关。Perl脚本在命令行上运行到完成需要很长时间。但是在.NET中,命令几乎立即返回,当我尝试重定向Perl脚本的标准输出以查看生成了什么消息时,它只显示第一行并返回。使用阻塞流读取技术无法解决此问题。NET确实认为Perl脚本只输出一行,然后就完成了

有什么建议吗?尽管我很想,但脚本不能在.NET中重写。下面是我用来启动流程的代码。我尝试将
ReadToEnd()
更改为一系列
ReadLine()
调用,但在第一次调用返回第一行输出后,下一次调用返回null

Process proc = new Process();
proc.StartInfo.FileName = scriptPath;
proc.StartInfo.Arguments = arguments;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.UseShellExecute = false;
proc.Start();
string output = proc.StandardOutput.ReadToEnd(); // Returns only the first line
proc.WaitForExit();

切换最后两行:

lineproc.WaitForExit();
string output = proc.StandardOutput.ReadToEnd(); // Returns only the first 
或者构建一个循环,在脚本完成之前一直从proc.StandardOutput读取数据