我正在尝试使用带有正则表达式模式的egrep来匹配空格.
我之前使用过PerEx和C#的RegEx,它们都支持\s搜索空格的模式.egrep(或至少我正在使用的版本)似乎不支持这种模式.
在网上的一些文章中,我遇到了一个简写[[:space:]],但这似乎不起作用.任何帮助表示赞赏.
使用:SunOS 5.10
我正在尝试访问命令行并执行命令,然后将输出返回到我的aspx页面.一个很好的例子是在aspx页面的页面加载上运行dir并通过Response.Write()返回输出.我尝试过使用下面的代码.当我尝试调试它时,它会运行,但永远不会完成加载,也不会呈现输出.我正在使用C#和.NET Framework 3.5sp1.任何帮助非常感谢.
谢谢,布莱恩
public partial class CommandLine : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
System.Diagnostics.Process si = new System.Diagnostics.Process();
si.StartInfo.WorkingDirectory = @"c:\";
si.StartInfo.UseShellExecute = false;
si.StartInfo.FileName = "cmd.exe";
si.StartInfo.Arguments = "dir";
si.StartInfo.CreateNoWindow = true;
si.StartInfo.RedirectStandardInput = true;
si.StartInfo.RedirectStandardOutput = true;
si.StartInfo.RedirectStandardError = true;
si.Start();
string output = si.StandardOutput.ReadToEnd();
si.Close();
Response.Write(output);
}
}
Run Code Online (Sandbox Code Playgroud)