如何将此列表发送到Python脚本中?这对于作为争论的人来说太大了。谢谢。
List<String> cefList= new List<String>();
for(int i=0; i<1000; i++){
cefList.Add("CEF:0|ArcSight|ArcSight|6.0.3.6664.0|agent:030|Agent [test] type [testalertng] started|Low|
eventId=1 mrt=1396328238973 categorySignificance=/Normal categoryBehavior=/Execute/Start
categoryDeviceGroup=/Application catdt=Security Mangement categoryOutcome=/Success
categoryObject=/Host/Application/Service art=1396328241038 cat=/Agent/Started
deviceSeverity=Warning rt=1396328238937 fileType=Agent
cs2=<Resource ID\="3DxKlG0UBABCAA0cXXAZIwA\=\="/> c6a4=fe80:0:0:0:495d:cc3c:db1a:de71
cs2Label=Configuration Resource c6a4Label=Agent
IPv6 Address ahost=SKEELES10 agt=888.99.100.1 agentZoneURI=/All Zones/ArcSight
System/Private Address Space
Zones/RFC1918: 888.99.0.0-888.200.255.255 av=6.0.3.6664.0 atz=Australia/Sydney
aid=3DxKlG0UBABCAA0cXXAZIwA\=\= at=testalertng dvchost=SKEELES10 dvc=888.99.100.1
deviceZoneURI=/All Zones/ArcSight System/Private Address Space Zones/RFC1918:
888.99.0.0-888.200.255.255 dtz=Australia/Sydney _cefVer=0.1");
}发布于 2016-08-16 07:23:01
由于您的C#程序运行python脚本,我想最简单的解决方案是重定向python进程的标准输入:
Process pyProc = Process.Start(
new ProcessStartInfo("python.exe", @"/path/to/the/script.py")
{
RedirectStandardInput = true,
UseShellExecute = false
}
);
for (int ii = 0; ii < 100; ++ii)
{
pyProc.StandardInput.WriteLine(string.Format("this is message # {0}", ii));
}在python脚本端,只需使用内置函数输入,如下所示(请注意,函数已在3.x中重命名为raw_input ):
while True:
data = raw_input()
print(data)发布于 2016-08-16 06:34:51
您需要将数据序列化为可从C#和Python访问的通用格式。例如- XML或JSON。我建议使用JSON。
然后你有几种选择:
套接字可能会更快。使用http可能更容易。对于文件,您需要有某种调度或通知系统,以便在写入文件时让Python程序知道。
https://stackoverflow.com/questions/38967979
复制相似问题