I am trying to call route -n in cgic code but popen returns null. I tried with a simple C code and it works but when i put it in cgi it returns null.
printf("Content-type: text/html\r\n");
printf("\r\n");
....
..
stream = popen("route -n", "r");
while ( fgets(buffer, 100, stream) != NULL )
{........}
it doesn’t enter the while loop. I can call “cat” “netstat” etc but route -n doesn’t work.
If I’m looking into my linux box, I see that
routeis located under/sbin/routeand is therefore not part of the$PATHfor standard users (while it’s executable for them on my system).catandnetstatare located under/bin/and therefore are part of the$PATH.will bring up the process.
If this is no option, add
/sbin/to your path and it will also work in your example.