Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
cgi中的呼叫路由-n_C_Cgi_Routes - Fatal编程技术网

cgi中的呼叫路由-n

cgi中的呼叫路由-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

我试图在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, stream) != NULL )
        {........}

它不会进入while循环。我可以调用cat netstat等,但route-n不起作用。

如果我查看我的linux框,我会看到该路由位于/sbin/route下,因此对于标准用户来说,它不是$PATH的一部分,而对于我的系统来说,它是可执行的

cat和netstat位于/bin/下,因此是$PATH的一部分

我们将提出这个过程

如果没有这个选项,请将/sbin/添加到路径中,它在您的示例中也会起作用

popen("/sbin/route -n", "r");