home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!europa.eng.gtefsd.com!darwin.sura.net!newsserver.jvnc.net!yale.edu!ira.uka.de!math.fu-berlin.de!news.netmbx.de!Germany.EU.net!mcsun!news.funet.fi!hydra!klaava!wirzeniu
- From: wirzeniu@klaava.Helsinki.FI (Lars Wirzenius)
- Subject: Re: Where does system("cd ./sudir") go ?
- Message-ID: <1993Jan28.172809.4614@klaava.Helsinki.FI>
- Organization: University of Helsinki
- References: <C1JMDn.9Gw@acsu.buffalo.edu>
- Date: Thu, 28 Jan 1993 17:28:09 GMT
- Lines: 26
-
- zshi@acsu.buffalo.edu (Zhixin Shi) writes:
- > I tried to make a program using system call to change dir, but when
- >I use
- > system("cd ./sudir")
- >it looks like going into the subdir then come back when the program
- >finished.
-
- The details of how system() works depend on the implementation and the
- environment where the program is run. On most systems, system()
- starts a new program (command interpreter or shell) to execute the
- command given to it. On some system, when the shell (or whatever)
- changes _its_ work directory, it doesn't affect any other program.
- This is the case with Unix, for example (your example would indicate
- Unix, or something very similar). On other systems (MS-DOS, for
- example) it _does_ affect, and changes the work directory for all
- programs.
-
- > Is there any idea how to make the program stay into the subdir or
- >simply using some other calls to do this?
-
- There is no portable way. Under Unix and MS-DOS, look for the chdir()
- function.
-
- --
- Lars.Wirzenius@helsinki.fi (finger wirzeniu@klaava.helsinki.fi)
- MS-DOS, you can't live with it, you can live without it.
-