cgi中的呼叫路由-n
我试图在cgic代码中调用route-n,但popen返回null。我尝试使用一个简单的C代码,它可以工作,但当我把它放在cgi中时,它返回nullcgi中的呼叫路由-n,c,cgi,routes,C,Cgi,Routes,我试图在cgic代码中调用route-n,但popen返回null。我尝试使用一个简单的C代码,它可以工作,但当我把它放在cgi中时,它返回null printf("Content-type: text/html\r\n"); printf("\r\n"); .... .. stream = popen("route -n", "r"); while ( fgets(buffer, 100, strea
printf("Content-type: text/html\r\n");
printf("\r\n");
....
..
stream = popen("route -n", "r");
while ( fgets(buffer, 100, stream) != NULL )
{........}
它不会进入while循环。我可以调用cat netstat等,但route-n不起作用。如果我查看我的linux框,我会看到该路由位于/sbin/route下,因此对于标准用户来说,它不是$PATH的一部分,而对于我的系统来说,它是可执行的 cat和netstat位于/bin/下,因此是$PATH的一部分 我们将提出这个过程 如果没有这个选项,请将/sbin/添加到路径中,它在您的示例中也会起作用
popen("/sbin/route -n", "r");