1)以下系统调用工作正常:
#define LOG_FILE_PATH "/tmp/logfile"
system("awk -v PRI=\"$PRI\" '/^<'$PRI'>/' "LOG_FILE_PATH);
2)但是如果我用fork+execl来替换上面的系统:
pid = fork();
if (pid == 0) {
execl("/usr/bin/awk", "awk", "-v", "PRI=\"$PRI\"", "'/^<'$PRI'>/'", LOG_FILE_PATH, (char *)0);
} else {
/* parent */
}
我收到错误消息:
awk: cmd. line:1: Unexpected token