很抱歉,如果这是一个重复的问题,但我找不到明确的答案。
我试图使用IronPython从.NET中调用python脚本(dnstwist.py)。
public static void runDNSTwistPython(string url)
{
var ipy = Python.CreateRuntime();
dynamic test = ipy.UseFile("dnstwist-master\\dnstwist.py");
test.main();
}
我需要一种方法来调用它并将输出放在.csv文件中。我可以从命令行轻松完成此操作,但无法弄清楚如何在我的C#方法中执行此操作。
python dnstwist.py --csv google.com > output.csv
由于
答案 0 :(得分:0)
@ jacob-hall你可以使用C#Process类并传递命令行来执行这个类文档可以在这里找到Process
你的代码将是这样的:
<div class="row">
<form method="post" id="insert_form2" style="padding-right: 10px;">
<div class="table-repsonsive">
<span id="error"></span>
<table class="table table-bordered" id="item_table2">
<tr>
<th>Species</th>
<th>Product</th>
<th>Quantity</th>
<th>Value (Rs.)</th>
<th><button type="button" name="add2" class="btn btn-success btn-sm add2"><span class="glyphicon glyphicon-plus"></span></button></th>
</tr>
</table>
</div>
<br>
<div align="right">
<input type="submit" name="submit4" class="btn btn-info" value="Add" onclick="move4()">
</div>
</form>
</div>
<script>
$(document).ready(function(){
$(document).on('click', '.add2', function(){
var html = '';
html += '<tr>';
html += '<td><input type="text" name="species[]" class="form-control species" /></td>';
html += '<td><select name="product[]" class="form-control product"><option value="">---Select---</option><option value="reserved">Reserved</option><option value="protected">Protected</option><option value="Unclassed">Unclassed</option></select></td>';
html += '<td><input type="text" name="quantity[]" class="form-control quantity" /></td>';
html += '<td><input type="text" name="value[]" class="form-control value" /></td>';
html += '<td><button type="button" name="remove2" class="btn btn-danger btn-sm remove2"><span class="glyphicon glyphicon-minus"></span></button></td></tr>';
$('#item_table2').append(html);
});
$(document).on('click', '.remove2', function(){
$(this).closest('tr').remove();
});
$('#insert_form2').on('submit', function(event){
event.preventDefault();
var error = '';
$('.species').each(function(){
var count = 1;
if($(this).val() == '')
{
error += "<p>Enter Item Name at "+count+" Row</p>";
return false;
}
count = count + 1;
});
$('.product').each(function(){
var count = 1;
if($(this).val() == '')
{
error += "<p>Enter Item Quantity at "+count+" Row</p>";
return false;
}
count = count + 1;
});
$('.quantity').each(function(){
var count = 1;
if($(this).val() == '')
{
error += "<p>Select Unit at "+count+" Row</p>";
return false;
}
count = count + 1;
});
$('.value').each(function(){
var count = 1;
if($(this).val() == '')
{
error += "<p>Select Unit at "+count+" Row</p>";
return false;
}
count = count + 1;
});
var form_data = $(this).serialize();
if(error == '')
{
$.ajax({
url:"insert2.php",
method:"POST",
data:form_data,
success:function(data)
{
if(data == 'ok')
{
$('#item_table2').find("tr:gt(0)").remove();
}
}
});
}
});
});
</script>