[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: [PROGRAMMERING] cd erstatning



Peter Makholm writes:

> Med mindre man altså snyder:
>
> #include <stdio.h> 
> #include <stdlib.h> 
> #include <unistd.h> 
>  
> int main(int argc, char *argv[]) 
> { 
>   if(argc != 2) 
>   { 
>     printf("Usage is: chdir <directory>\n"); 
>     exit(1); 
>   } 
>  
>   printf("Trying to change directory to %s\n", argv[1]); 
>   int r = chdir(argv[1]); 
>  
>   if(r != 0) 
>   { 
>     printf("An error has occured\n"); 
>     exit(1); 
>   } 
>  
>   printf("Directory succesfulled changed to %s\n", getcwd(NULL,0)); 
>
>   char *shell = getenv("SHELL");
>   
>   if (execlp(shell,shell,NULL) != 0) {
>           perror("Couldn't exec $SHELL");
>           exit(1);
>   }
>   
>   exit(0); 
> }

Det er en fræk løsning, men den giver i det mindste umiddelbart den
rette illusion.

Jeg stemmer for at Jeppes lærer skylder Peter en flaske Corsendonk
Christmas Ale. ;-)

Jacob
-- 
»... meget nemmere, hvis du ville huske at spørre om det,
 som jég svarer på!«               -- Divus Madsen, exam.gud


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2006-01-01, 02:01 CET [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] *