[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] Kort, dumt spørgsmål



Ret skal være ret. Prøvede lige samme mekanik på min server, og så giver
den med argv[0] og realpath faktisk den fulde path til programmet. Jeg
skal faktisk ikke bruge programmets navn, så jeg kører videre med
getcwd. Jeg skal bare finde et subdirectory til programmets. Alle er
glade!!

Søren


Mads Bondo Dydensborg wrote:
> 
> On Thu, 11 Oct 2001, Søren H. Sørensen wrote:
> 
> > Det ville virke hvis argv[0] havde den fulde path. Det har den hvis
> > programmet startes fra en shell, men ikke når det startes fra en
> > webserver. Der indeholder argv[0] nemlig kun programmets navn. realpath
> > gør ikke andet end at udvide "." og ".." til rigtige navne, og det er
> > ikke nødvendigt ved en normal argv[0] fra en shell (det ved jeg dog kun
> > fra DOS-verdenen).
> 
> Hmm. Der står eksplicit at der returneres en absolut sti.
> 
> sslug@sslug tmp]$ cat mytest.c
> #include <limits.h>
> #include <stdlib.h>
> #include <stdio.h>
> 
> int main(int argc, char ** argv) {
>    char buf[PATH_MAX];
>    printf("argv[0] = %s\n", argv[0]);
>    if (realpath(argv[0], buf)) {
>       printf("realpath = %s\n", buf);
>    } else {
>       printf("error\n");
>    }
>    return 0;
> }
> sslug@sslug tmp]$ gcc -Wall -o mytest mytest.c
> sslug@sslug tmp]$ export PATH=$PATH:.
> sslug@sslug tmp]$ mytest
> argv[0] = mytest
> realpath = /home/madsdyd/tmp/mytest
> sslug@sslug tmp]$
> 
> Jeg ville mene at det burde virke, også for en webserver.
> 
> Mads
> 
> --
> Mads Bondo Dydensborg.                               sslug@sslug
> The Microsoft Dictionary:
> 
>            interoperability: The ability of a Microsoft product to operate
>                              with another Microsoft product.


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:09 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *