linux - Variables variables through pipes c# -
hi i'm trying use pipes redirect standard output , standard error process, far made possible send , receive data using console.readline() server client pipes i've been looking away send variables (like standard output/error)
namedpipeclient:
static void client(){ while (true){ var clientstream = new namedpipeclientstream("ouput"); clientstream.connect(60); string line = console.readline(); byte[] buffer = asciiencoding.ascii.getbytes(line); clientstream.write(buffer,0,buffer.length); if (line.tolower() == "cerrar") break; clientstream.close(); } } server pipe:
static void server(){ while (true){ var namedpipeserverstream = new namedpipeserverstream("output"); namedpipeserverstream.waitforconnection(); byte[] buffer = new byte[255]; namedpipeserverstream.read(buffer, 0, 255); string request = asciiencoding.ascii.getstring(buffer); console.writeline(request); request=request.trim('\0'); if(request.tolower()=="cerrar") break; namedpipeserverstream.close(); } } this how start process:
process process = new system.diagnostics.process(); process.startinfo.filename = "/bin/bash"; process.startinfo.arguments = "-c " + pathfile + " \""; process.startinfo.useshellexecute = false; process.startinfo.redirectstandardoutput = true; process.startinfo.redirectstandarderror = true; process.start(); string output = process.standardoutput.readtoend(); string error = process.standardoutput.readtoend(); process.waitforexit(); the idea take vars output , error , send them pipes have.
thank in advance.
Comments
Post a Comment