home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / msdos / programm / 11864 < prev    next >
Encoding:
Text File  |  1993-01-07  |  1.6 KB  |  36 lines

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!gatech!usenet.ins.cwru.edu!ncoast!brown
  3. From: brown@NCoast.ORG (Stan Brown)
  4. Subject: Re: question on spawning DOS from C prog
  5. Organization: Oak Road Systems, Cleveland Ohio USA
  6. Date: Thu, 7 Jan 1993 15:20:37 GMT
  7. Message-ID: <C0HpAD.Lny@NCoast.ORG>
  8. References: <1993Jan5.212229.57639@ns1.cc.lehigh.edu> <1iedifINNmoi@infoac.rmi.de> <tim.36.726368023@tim.src.utah.edu>
  9. Lines: 25
  10.  
  11. In article <tim.36.726368023@tim.src.utah.edu> tim@tim.src.utah.edu (Tim Ma) writes:
  12. >>In your function declare something like:
  13. >>    static char prompt[]="PROMPT=<Type EXIT to return to program>$_$_$P";
  14. >>and before the spawnl() do a
  15. >>    putenv(prompt);
  16. [to display a custom prompt in a spawned DOS session]
  17.  
  18. >Is this possible?  It was my understanding that 'spawn' called a new command 
  19. >shell so any changes in the environment would not be carried over.
  20.  
  21. spawn does indeed call a new command shell.  But the environment in that
  22. shell is a copy of the environment block of the program that created the
  23. shell.  So the suggeted solution is the right thing to do: it modifies
  24. the prompt string in the program's copy of the environment, and then the
  25. spawned shell inherits the modified environment.
  26.  
  27. When the user types EXIT to return from shell to program, and then later
  28. the program itself ends, the environment is unchanged because the putenv
  29. call modifies only the program's copy of the environment, not "the"
  30. envronment belonging to the original DOS shell at boot-up.
  31.  
  32. The FAQ list sheds a little light on some related questions.
  33. -- 
  34. Stan Brown, Oak Road Systems                      brown@Ncoast.ORG
  35. Cleveland, Ohio, USA
  36.