Re: system in Linux (was getenv in Linux)
- Posted by Pete Eberlein <xseal at HARBORSIDE.COM> Sep 20, 1999
- 408 views
On Mon, 20 Sep 1999 06:56:37 -0400, Irv Mullins <irv at ELLIJAY.COM> wrote: >On Sun, 19 Sep 1999, you wrote: > >> So the problem is actually with using system under Linux. Example: >> DOS: system("cd c:\\",2) -- current_dir() returns "c:\" after >> Linux: system("cd /",2) -- but current_dir() doesn't return "/" after > >Correct. system("cd /",2) won't change the directory on my computer either. >In fact, sytem won't change directories _at all_ under Linux.. >Rob? > >Irv The system() command creates a sub-shell for the program to be run, with it's own environment variables, etc. When you change directories in that shell, it doesn't affect the parent shell (from which exu was run) at all. The parent shell which is where I suspect current_dir() gets its information. You can do multiple shell commands within the same system statement by separating each of them by a semicolon ";" system("cd / ; ls", 2) The annoying thing about this is that you can't see the results of the command until after exu exits because ncurses gets in the way, I think. Later, _______ ______ _______ ______ [ _ \[ _ ][ _ _ ][ _ ] [/| [_] |[/| [_\][/ | | \][/| [_\] | ___/ | _] | | | _] [\| [/] [\| [_/] [\| |/] [\| [_/] [_____] [______] [_____] [______] xseal at harborside.com ICQ:13466657 http://www.harborside.com/home/x/xseal/euphoria/