Setting UNIX Path from C 
Author Message
 Setting UNIX Path from C

Does anyone know how to set the PATH variable from C . I have tried
setenv with PATH and the path as parameters to no avail

HELP PLEASE !!!!

Shaw Green



Sun, 11 Jan 1998 03:00:00 GMT  
 Setting UNIX Path from C

Quote:
> Does anyone know how to set the PATH variable from C . I have tried
> setenv with PATH and the path as parameters to no avail

From the comp.lang.c FAQ available at rtfm.mit.edu:

----CUT HERE----Cut Here----cut here----CUT HERE----Cut Here----cut here----
16.6:   How can a process change an environment variable in its caller?

A:      In general, it cannot.  Different operating systems implement
        name/value functionality similar to the Unix environment in
        different ways.  Whether the "environment" can be usefully
        altered by a running program, and if so, how, is system-
        dependent.

        Under Unix, a process can modify its own environment (some
        systems provide setenv() and/or putenv() functions to do this),
        and the modified environment is usually passed on to any child
        processes, but it is _not_ propagated back to the parent
        process.
----CUT HERE----Cut Here----cut here----CUT HERE----Cut Here----cut here----

                                               -michael
--
Michael Jarvis   |  Finger for PGP Public key  |   QNSnet Technical Support

GCS d H- s+++: g? p+ au a25 w+ v C++++ USL++++$ P++++ L++>+++ 3- E--- N++ K
W-- M- !V po Y+ t+ 5 j R G+ tv b+++ D++ B- e+>++ u+ h---(*) f+ r+++ !n y+++



Sun, 11 Jan 1998 03:00:00 GMT  
 Setting UNIX Path from C

Quote:
>Does anyone know how to set the PATH variable from C . I have tried
>setenv with PATH and the path as parameters to no avail

There is no portable way to set environment variables in a C program.
For Unix, try "man putenv".  And don't forget that you can change only
the environment of your process, which will be inherited by your process'
children but _not_ sent back to your process' parent.

Dan
--
Dan Pop
CERN, CN Division

Mail:  CERN - PPE, Bat. 31 R-004, CH-1211 Geneve 23, Switzerland



Mon, 12 Jan 1998 03:00:00 GMT  
 Setting UNIX Path from C

Quote:
>Does anyone know how to set the PATH variable from C . I have tried
>setenv with PATH and the path as parameters to no avail
>HELP PLEASE !!!!
>Shaw Green

    The solution is in the Unix FAQs....


Mon, 12 Jan 1998 03:00:00 GMT  
 Setting UNIX Path from C

|>
|>
|> >Does anyone know how to set the PATH variable from C . I have tried
|> >setenv with PATH and the path as parameters to no avail
|>
|> There is no portable way to set environment variables in a C program.
|> For Unix, try "man putenv".  And don't forget that you can change only
|> the environment of your process, which will be inherited by your process'
|> children but _not_ sent back to your process' parent.
|>
This is not a c.l.c question.  It should be asked in the appropriate
newsgroup for the platform of interest to the original poster.
--
| Chick Racer                     Chevron Petroleum Technology Co. |
| (713) 596-2430                  P.O. Box 42832                   |

| 4119 Hayes Rd.                                                   |


Sun, 18 Jan 1998 03:00:00 GMT  
 Setting UNIX Path from C


: |>
: |>
: |> >Does anyone know how to set the PATH variable from C . I have tried
: |> >setenv with PATH and the path as parameters to no avail
: |>
: |> There is no portable way to set environment variables in a C program.
: |> For Unix, try "man putenv".  And don't forget that you can change only
: |> the environment of your process, which will be inherited by your process'
: |> children but _not_ sent back to your process' parent.
: |>
: This is not a c.l.c question.  It should be asked in the appropriate
: newsgroup for the platform of interest to the original poster.
: --
: | Chick Racer                     Chevron Petroleum Technology Co. |
: | (713) 596-2430                  P.O. Box 42832                   |

: | 4119 Hayes Rd.                                                   |


Sun, 25 Jan 1998 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Newbie: separate big .cs file into small .cs files

2. How to get executable full path name on unix system

3. C and Unix method: access (char *path, int amode)

4. fopen() with a UNIX path?

5. how to set environment variable to lib path?

6. Stupid Question: How to set the include path

7. Setting up symbols and path to use devenv.exe

8. lib readline and setting path for tab-completion

9. error iostream.h no include path set

10. how to set path for BorlandC++

11. C-code for the LONGEST PATH between a set of Points

12. where are the default paths set up?

 

 
Powered by phpBB® Forum Software