Path / Environment in unix

This is a discussion on Path / Environment in unix within the C Programming forums, part of the General Programming Boards category; Dear all, I've been trying to get the value of the PATH variable (unix) from a C program. The only ...

  1. #1
    Unregistered
    Guest

    Talking Path / Environment in unix

    Dear all,

    I've been trying to get the value of the PATH variable (unix) from a C program. The only thing I could think of is to loop through the .login file, but that seems like an overkill. Is there a simpler way to do this?

    Thanks,

    Fred

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    11
    Hi,

    getenv() function can be used

    just include stdlib.h

    #include<stdlib.h>

    main()
    {
    printf("%s",getenv("PATH"));
    }

    And this should do .

    Be HAPPY

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Files in Unix environment.
    By kwikness in forum C Programming
    Replies: 3
    Last Post: 10-06-2007, 04:12 PM
  2. added start menu crashes game
    By avgprogamerjoe in forum Game Programming
    Replies: 6
    Last Post: 08-29-2007, 01:30 PM
  3. Retrieving PATH Environment Variable
    By mercury529 in forum Windows Programming
    Replies: 9
    Last Post: 01-09-2007, 07:02 PM
  4. Setting path environment variable
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 09-01-2006, 03:03 PM
  5. Windows or Unix environment
    By ghe1 in forum Windows Programming
    Replies: 5
    Last Post: 02-19-2002, 10:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21