running bash piped comand from mono linux -
i trying run bash command pipe using mono process start
here code snippet trying
single commands works, pipe commands fails run, missing here ?
processstartinfo oinfo = new processstartinfo(command, args); oinfo.useshellexecute = false; oinfo.createnowindow = true; oinfo.redirectstandardoutput = true; oinfo.redirectstandarderror = true; streamreader sroutput = null; streamreader srerror = null; process proc = system.diagnostics.process.start(oinfo); proc.waitforexit();
i tried running "ps -aux" runs fine. ps -aux | grep gnome command failed.
i tried these scenarios scenario 1: command = ps argument = -aux | grep gnome
scenario 2: command = ps argument = "-c ' -aux | grep gnome ' "
scenario 3 :
command = ps argument = " -c \" -aux | grep gnome \" "
all these failed
error: garbage option
usage: ps [options]
try 'ps --help ' or 'ps --help ' additional text.
also on side question, reason trying figure out of particular daemon running. there standard way info. instance in windows can query running services using servicecontroller.getservices().
is similar available on mono/linux directly ?
when add "|" bash line bash interpreter splits command in 2 processes , feeds output 1 other, when call command using process sends argument is.
the close can achieve start 2 process , feed 1 output of other through input/output streams.
about part 2 of question, if program runs privileged process.getprocesses list running processes on system included daemons.
Comments
Post a Comment