c++ - Getting extra character while caputuring system call output in c -


i capturing system call output using pipe. command running following :-

ps -ef | grep "/home/code/service" | grep 14011 | awk '{print $nf}' 

when execute above command on command prompt give me 1 integer value 197.

when execute same command using pipe , getting following :-

$nf}' $nf}' 197 

above output order in random order , follwing :-

$nf}' 197 $nf}' 


using similar code( waqas ) mentioned in below link :-

how execute command , output of command within c++ using posix?

i passing command pipe using following way :-

std::stringstream sstr ;  sstr<<"ps -ef | "; sstr<<"grep \"/home/code/service/\" | grep "; sstr<<ppid; sstr<<" | awk \'{print $nf}\'";  file* pipe = popen((sstr.str()).c_str(), "r"); 


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -