[MonoDevelop] [HowTo] Executing Shell Commands...
raz3r
daniele.raz3r at gmail.com
Wed Oct 20 05:57:10 EDT 2010
I need to execute a list of iptables commands that are sent by Socket
application. The Client is running on Windows and sends iptables commands
(one by one), the Server (made with Mono) is running on Linux and has to
execute each line of command that receive.
Each command looks like:
$IPTABLES...
Before commands i send this line to set the variable:
IPTABLES='iptables'
I tryed with this code:
.....
while (true)
{
bytesread = 0;
try
{
bytesread =
clientStream.Read(message, 0, 4096);
}
catch
{
break;
}
if (bytesread == 0)
break;
//Executing: $IPTABLES COMMAND
ASCIIEncoding encoding = new
ASCIIEncoding();
Console.WriteLine("Executing:
"+encoding.GetString(message, 0, bytesread));
System.Diagnostics.Process proc = new
System.Diagnostics.Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = ""; ????????????
proc.StartInfo.Arguments =
encoding.GetString(message, 0, bytesread);
proc.Start();
//SENDING OK
string toSend = "OK";
byte[] buffer = encoding.GetBytes(toSend);
clientStream.Write(buffer, 0,
buffer.Length);
proc.Close();
}
.....
What is this FileName parameter? I do not know how to configure this one...
Can you help me?
--
View this message in context: http://mono.1490590.n4.nabble.com/HowTo-Executing-Shell-Commands-tp3003573p3003573.html
Sent from the Mono - MonoDevelop IDE mailing list archive at Nabble.com.
More information about the Monodevelop-list
mailing list