Home > OS >  Linux system function calls shell command error solution?
Linux system function calls shell command error solution?

Time:11-01

The great god who met this wonderful work problems:
Using the system call system command error:
Char * command="ps aux | sort - nr - 4 k | 3 sort - nr - k | head - n 12 | grep -v" USER "| awk '{printf" % - 10 s % - 10 s % - 10 s % - 10 s \ n ", $1, $2, $3, $11}' "
The FILE * fp=popen (command, "r");
Compile error:
: "1: error: expected ', 'or'; 'before' USER '
: just 5: error: invalid suffix "s" on the integer constant
Destruction is 1: error: invalid suffix "s" on the integer constant
Destruction is 7: error: invalid suffix "s" on the integer constant
: with 3: error: invalid suffix "s" on the integer constant
: error: stray '\' in the program

No problem in the console window separate executes the command

CodePudding user response:

Should be the problem of the quotation marks, more than double quotation marks, matching the wrong

CodePudding user response:

Quotes to escape, or use the grep -v "USER" to grep -v 'USER',
  • Related