I’m using lighttpd and wrote the following cgi script:
main(){
printf("Content-type: text/html\n\n");
char * pwd ="";
pwd=getenv("PWD");
printf ("The current path is: %s",pwd);
}
The Result is
The current path is: (null)
Well, I don’t get why. And I don’t know how to find the path of the script executed. I’m looking for args[0] with a path, and used pwd for that, but maybe I should switch to something different.
UPDATE
Not working aswell is
char cwd[_PC_PATH_MAX+1];
getcwd(cwd, _PC_PATH_MAX+1);
cwd is ” “. Maybe my script knew where it was if I stoped using room 1408 as my datacenter. 😛
Use
getcwd()instead.PWDisn’t required to be set.